line |
stmt |
code |
1
|
|
# Copyright SUSE LLC |
2
|
|
# SPDX-License-Identifier: GPL-2.0-or-later |
3
|
|
|
4
|
|
|
5
|
|
use Mojo::Base -strict, -signatures; |
6
|
94
|
use Carp; |
|
94
|
|
|
94
|
|
7
|
94
|
use Mojo::File qw(path); |
|
94
|
|
|
94
|
|
8
|
94
|
use Mojo::Log; |
|
94
|
|
|
94
|
|
9
|
94
|
use POSIX 'strftime'; |
|
94
|
|
|
94
|
|
10
|
94
|
use Time::HiRes qw(gettimeofday); |
|
94
|
|
|
94
|
|
11
|
94
|
use Time::Moment; |
|
94
|
|
|
94
|
|
12
|
94
|
use Term::ANSIColor; |
|
94
|
|
|
94
|
|
13
|
94
|
use Exporter 'import'; |
|
94
|
|
|
94
|
|
14
|
94
|
our @EXPORT_OK = qw(logger init_logger diag fctres fctinfo fctwarn modstate); |
|
94
|
|
|
94
|
|
15
|
|
|
16
|
|
our $logger; |
17
|
|
our $direct_output; |
18
|
|
|
19
|
|
|
20
|
3448
|
|
|
3448
|
|
|
3448
|
|
21
|
|
my $lines = join("\n", @items, ''); |
22
|
38
|
|
|
38
|
|
|
38
|
|
23
|
|
# ensure indentation for multi-line output |
24
|
1673
|
$lines =~ s/(?<!\A)^/ /gm; |
|
1673
|
|
|
1673
|
|
|
1673
|
|
|
1673
|
|
25
|
1673
|
|
26
|
|
return '[' . Time::Moment->now . "] [$level] $lines"; |
27
|
|
} |
28
|
1673
|
|
29
|
|
confess "missing input" unless @args; |
30
|
1673
|
logger->append(color('white')); |
31
|
|
logger->debug(@args)->append(color('reset')); |
32
|
|
return; |
33
|
1099
|
} |
|
1099
|
|
|
1099
|
|
34
|
1099
|
|
35
|
1099
|
$fname //= (caller(1))[3]; |
36
|
1099
|
logger->append(color('green')); |
37
|
1099
|
logger->debug(">>> $fname: $text")->append(color('reset')); |
38
|
|
return; |
39
|
|
} |
40
|
4
|
|
|
4
|
|
|
4
|
|
|
4
|
|
41
|
4
|
$fname //= (caller(1))[3]; |
42
|
4
|
logger->append(color('yellow')); |
43
|
4
|
logger->info("::: $fname: $text")->append(color('reset')); |
44
|
4
|
return; |
45
|
|
} |
46
|
|
|
47
|
87
|
$fname //= (caller(1))[3]; |
|
87
|
|
|
87
|
|
|
87
|
|
48
|
87
|
logger->append(color('red')); |
49
|
87
|
logger->warn("!!! $fname: $text")->append(color('reset')); |
50
|
87
|
return; |
51
|
87
|
} |
52
|
|
|
53
|
|
logger->append(color('bold blue')); |
54
|
278
|
logger->debug("||| @{[join(' ', @text)]}")->append(color('reset')); |
|
278
|
|
|
278
|
|
|
278
|
|
55
|
278
|
return; |
56
|
278
|
} |
57
|
278
|
|
58
|
278
|
1; |