DiaColloDB/Logger.pm

filter: Statementstmt 20.0% 19 / 95 Branchbran 6.4% 4 / 62 Conditioncond 0.0% 0 / 34 MC/DCmcdc 0.0% 0 / 21 Subroutinesub 16.1% 5 / 31 Podpod 100% 22 / 22 totaltotal 18.8% 50 / 265 CC 45 SCAR 55.2
CC
45
Cov
12%
defaultLogConf
702.0
vlog
30.0
haveFileRotate
20.0
CRAP 249.4
« DiaColloDB/Relation/TDF.pm ↑ Summary DiaColloDB/Document/TEI.pm »
1 ## -*- Mode: CPerl -*-
2 ##
3 ## File: DiaColloDB::Logger.pm
4 ## Author: Bryan Jurish <moocow@cpan.org>
5 ## Description: DiaColloDB logging (using Log::Log4perl)
6  
7 package DiaColloDB::Logger;
8 #use DiaColloDB::Utils ':profile';
9 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Log::Log4perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 ##==============================================================================
15 ## Globals
16 ##==============================================================================
17  
18 2 our @ISA = qw();
19  
20 2 our ($MIN_LEVEL); ##-- minimum log level
21 2 our (%defaultLogOpts); ##-- default log options
22 2 ▶BEGIN {
Subroutine BEGIN: called CC=5 SCAR=18.2
23 2 $MIN_LEVEL = $Log::Log4perl::Level::LEVELS{(sort {$a<=>$b} keys(%Log::Log4perl::Level::LEVELS))[0]};
24 2 ▶ %defaultLogOpts =
Branch: 4 branches
BranchTrueFalseTotal
$^W ? : 0 2 2
$^W ? : 0 2 2
$^W ? : 0 2 2
$0 =~ /(?:server|daemon)/i ? : 0 2 2
25 (
26 l4pfile => undef, ##-- formerly $logConfigFile
27 watch => undef, ##-- watch l4pfile (undef or secs)?
28 rootLevel => ($^W ? 'WARN' : 'FATAL'),
29 level => ($^W ? $MIN_LEVEL : 'INFO'),
30 stderr => 1,
31 logdate => 1,
32 logtime => 1,
33 logwhich => [qw(DiaColloDB DocClassify DDC.XS DTA.CAB DTA.TokWrap DWDSTermClassifier)],
34 file => undef,
35 rotate => undef, ##-- default: haveFileRotate()
36 syslog => 0,
37 sysLevel => ($^W ? 'debug' : 'info'),
38 sysName => File::Basename::basename($0),
39 sysIdent => undef, ##-- default=$opts{sysName}
40 sysFacility => ($0 =~ m/(?:server|daemon)/i ? 'daemon' : 'user'),
41 );
42 }
43  
44 ## $DEFAULT_LOG_CONF = PACKAGE->defaultLogConf(%opts)
45 ## + default configuration for Log::Log4perl
46 ## + see Log::Log4perl(3pm), Log::Log4perl::Config(3pm) for details
47 ## + %opts:
48 ## rootLevel => $LEVEL_OR_UNDEF, ##-- min root log level (default='WARN' or 'FATAL', depending on $^W)
49 ## level => $LEVEL_OR_UNDEF, ##-- min log level (default=$MIN_LEVEL or 'INFO', depending on $^W)
50 ## stderr => $bool, ##-- whether to log to stderr (default=1)
51 ## logtime => $bool, ##-- whether to log time-stamps on stderr (default=0)
52 ## logdate => $bool, ##-- whether to log date+time-stamps on stderr (default=0)
53 ## logwhich => \@classes, ##-- log4perl-style classes to log (default=qw(DiaColloDB DocClassify DTA.CAB DTA.TokWrap))
54 ## file => $filename, ##-- log to $filename if true
55 ## rotate => $bool, ##-- use Log::Dispatch::FileRotate if available and $filename is true
56 ## syslog => $bool, ##-- use Log::Dispatch::Syslog if available and true (default=false)
57 ## sysLevel => $level, ##-- minimum level for syslog (default='debug' or 'info', depending on $^W)
58 ## ## : available levels: debug,info,notice,warning,error,critical,alert,emergency (== 0..7)
59 ## sysName => $sysName, ##-- name for syslog (default=basename($0))
60 ## sysIdent => $sysIdent, ##-- ident string for syslog (default=$sysName)
61 ## sysFacility => $facility, ##-- facility for syslog (default='daemon')
62 0 ▶sub defaultLogConf {
Subroutine defaultLogConf: not called CC=26 SCAR=65.5
Pod documented
63 0 my ($that,%opts) = @_;
64 0 %opts = (%defaultLogOpts,%opts);
65 0 ▶ $opts{rotate} = haveFileRotate() if (defined($opts{file}) && !defined($opts{rotate}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"file"} and not defined $opts{"rotate"} 0 0 0
Condition0%0/3
defined $opts{"file"} and not defined $opts{"rotate"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $opts{"file"} and not defined $opts{"rotate"}
defined $opts{"file"} not defined $opts{"rotate"}
Truth table0%0/3
A and not(B)
A= defined $opts{"file"}B= not defined $opts{"rotate"}
ABresult
0X0
100
111
66 0 ▶ $opts{sysIdent} = $opts{sysName} if (!defined($opts{sysIdent}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts{"sysIdent"} 0 0 0
67  
68  
69 ##-- generate base config
70 0 my $cfg = "
71 ##-- Loggers
72 log4perl.oneMessagePerAppender = 1 ##-- suppress duplicate messages to the same appender
73 ";
74  
75 0 ▶ if ($opts{rootLevel}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"rootLevel"}) 0 0 0
76 ##-- root logger
77 0 $cfg .= "log4perl.rootLogger = $opts{rootLevel}, AppStderr\n";
78 }
79  
80 0 ▶ if ($opts{stderr} || $opts{file} || $opts{syslog}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"stderr"} or $opts{"file"} or $opts{"syslog"}) 0 0 0
Condition0%0/6
$opts{"stderr"} or $opts{"file"} or $opts{"syslog"}
l!l&&r!l&&!r
000
$opts{"stderr"} or $opts{"file"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$opts{"stderr"} or $opts{"file"} or $opts{"syslog"}
$opts{"stderr"} $opts{"file"} $opts{"syslog"}
Truth table0%0/4
A or B or C
A= $opts{"stderr"}B= $opts{"file"}C= $opts{"syslog"}
ABCresult
1XX1
01X1
0011
0000
81 ##-- local package logger(s)
82 0 ▶ if ($opts{level}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"level"}) 0 0 0
83 0 ▶ my $which = $opts{logwhich} // [qw(DiaColloDB DocClassify DTA.CAB DTA.TokWrap)];
Condition0%0/2
$opts{"logwhich"} // ["DiaColloDB", "DocClassify", "DTA.CAB", "DTA.TokWrap"]
l!l
00
MC/DC0%0/1
$opts{"logwhich"} // ["DiaColloDB", "DocClassify", "DTA.CAB", "DTA.TokWrap"]
$opts{"logwhich"}
Truth table0%0/2
A
A= $opts{"logwhich"}
Aresult
11
00
84 0 ▶ $which = [grep {($_//'') ne ''} split(/[\,\s]+/,$which)] if ($which && !ref($which));
Branch: 1 branch
BranchTrueFalseTotal
if $which and not ref $which 0 0 0
Condition0%0/5
$which and not ref $which
!ll&&!rl&&r
000
$_ // ""
l!l
00
MC/DC0%0/2
$which and not ref $which
$which not ref $which
MC/DC0%0/1
$_ // ""
$_
Truth table0%0/3
A and not(B)
A= $whichB= not ref $which
ABresult
0X0
100
111
Truth table0%0/2
A
A= $_
Aresult
11
00
85 0 foreach (@$which) {
86 $cfg .= "log4perl.logger.$_ = $opts{level}, ".join(", ",
87 ($opts{stderr} ? 'AppStderr' : qw()),
88 ($opts{file} ? 'AppFile' : qw()),
89 0 ▶ ($opts{syslog} ? 'AppSyslog' : qw()),
Branch: 3 branches
BranchTrueFalseTotal
$opts{'stderr'} ? : 0 0 0
$opts{'file'} ? : 0 0 0
$opts{'syslog'} ? : 0 0 0
90 )."\n";
91 }
92 }
93 ##-- avoid duplicate messages
94 0 $cfg .= "log4perl.additivity.DTA = 0\n";
95 }
96  
97 ##-- appenders: utils
98 0 $cfg .= "
99 ##-- Appenders: Utilities
100 log4perl.PatternLayout.cspec.G = sub { return File::Basename::basename(\"$::0\"); }
101 ";
102  
103 ##-- appender: stderr
104 my $stderr_date = (($opts{logdate} && $opts{logtime}) ? '%d{yyyy-MM-dd HH:mm:ss} '
105 0 ▶ : ($opts{logtime} ? '%d{HH:mm:ss} ' : ''));
Branch: 2 branches
BranchTrueFalseTotal
$opts{'logdate'} && $opts{'logtime'} ? : 0 0 0
$opts{'logtime'} ? : 0 0 0
Condition0%0/3
$opts{"logdate"} and $opts{"logtime"}
!ll&&!rl&&r
000
MC/DC0%0/2
$opts{"logdate"} and $opts{"logtime"}
$opts{"logdate"} $opts{"logtime"}
Truth table0%0/3
A and B
A= $opts{"logdate"}B= $opts{"logtime"}
ABresult
0X0
100
111
106 0 $cfg .= "
107 ##-- Appender: AppStderr
108 log4perl.appender.AppStderr = Log::Log4perl::Appender::Screen
109 log4perl.appender.AppStderr.stderr = 1
110 log4perl.appender.AppStderr.binmode = :utf8
111 log4perl.appender.AppStderr.layout = Log::Log4perl::Layout::PatternLayout
112 log4perl.appender.AppStderr.layout.ConversionPattern = ${stderr_date}%G[%P] %p: %c: %m%n
113 ";
114  
115 ##-- appender: syslog
116 0 ▶ if ($opts{syslog}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"syslog"}) 0 0 0
117 0 eval 'use Log::Dispatch::Syslog;';
118 0 ▶ die "could not use Log::Dispatch::Syslog: $@" if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
119 0 $cfg .= "
120 log4perl.appender.AppSyslog = Log::Dispatch::Syslog
121 log4perl.appender.AppSyslog.name = $opts{sysName}
122 log4perl.appender.AppSyslog.ident = $opts{sysIdent}
123 log4perl.appender.AppSyslog.min_level = $opts{sysLevel}
124 log4perl.appender.AppSyslog.facility = $opts{sysFacility}
125 log4perl.appender.AppSyslog.logopt = pid
126 log4perl.appender.AppSyslog.layout = Log::Log4perl::Layout::PatternLayout
127 log4perl.appender.AppSyslog.layout.ConversionPattern = (%p) %c: %m%n
128 ";
129 }
130  
131 0 ▶ if ($opts{file} && $opts{rotate}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opts{'file'} and $opts{'rotate'}) { } 0 0 0
elsif ($opts{'file'}) { } 0 0 0
Condition0%0/3
$opts{"file"} and $opts{"rotate"}
!ll&&!rl&&r
000
MC/DC0%0/2
$opts{"file"} and $opts{"rotate"}
$opts{"file"} $opts{"rotate"}
Truth table0%0/3
A and B
A= $opts{"file"}B= $opts{"rotate"}
ABresult
0X0
100
111
132 ##-- rotating file appender
133 0 eval 'use Log::Dispatch::FileRotate;';
134 0 ▶ die "could not use Log::Dispatch::FileRotate: $@" if ($@);
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
135 0 $cfg .= "
136 ##-- Appender: AppFile: rotating file appender
137 log4perl.appender.AppFile = Log::Dispatch::FileRotate
138 log4perl.appender.AppFile.min_level = debug
139 log4perl.appender.AppFile.filename = $opts{file}
140 log4perl.appender.AppFile.binmode = :utf8
141 log4perl.appender.AppFile.mode = append
142 log4perl.appender.AppFile.size = 10485760
143 log4perl.appender.AppFile.max = 10
144 log4perl.appender.AppFile.layout = Log::Log4perl::Layout::PatternLayout
145 log4perl.appender.AppFile.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} [%P] (%p) %c: %m%n
146 ";
147 }
148 elsif ($opts{file}) {
149 ##-- raw file appender
150 0 $cfg .= "
151 ##-- Appender: AppFile: raw file appender (no automatic log rotation)
152 log4perl.appender.AppFile = Log::Log4perl::Appender::File
153 log4perl.appender.AppFile.filename = $opts{file}
154 log4perl.appender.AppFile.mode = append
155 log4perl.appender.AppFile.utf8 = 1
156 log4perl.appender.AppFile.layout = Log::Log4perl::Layout::PatternLayoutl
157 log4perl.appender.AppFile.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} [%P] (%p) %c: %m%n
158 ";
159 }
160  
161 0 return $cfg;
162 }
163  
164 ## $bool = CLASS::haveFileRotate()
165 ## + returns true if Log::Dispatch::FileRotate is available
166 0 ▶sub haveFileRotate {
Subroutine haveFileRotate: not called CC=4 SCAR=30.0
Pod documented
167 0 ▶ return 1 if (defined($Log::Dispatch::FileRotate::VERSION));
Branch: 1 branch
BranchTrueFalseTotal
if defined $Log::Dispatch::FileRotate::VERSION 0 0 0
168 0 eval "use Log::Dispatch::FileRotate;";
169 0 ▶ return 1 if (defined($Log::Dispatch::FileRotate::VERSION) && !$@);
Branch: 1 branch
BranchTrueFalseTotal
if defined $Log::Dispatch::FileRotate::VERSION and not $@ 0 0 0
Condition0%0/3
defined $Log::Dispatch::FileRotate::VERSION and not $@
!ll&&!rl&&r
000
MC/DC0%0/2
defined $Log::Dispatch::FileRotate::VERSION and not $@
defined $Log::Dispatch::FileRotate::VERSION not $@
Truth table0%0/3
A and not(B)
A= defined $Log::Dispatch::FileRotate::VERSIONB= not $@
ABresult
0X0
100
111
170 0 $@='';
171 0 return 0;
172 }
173  
174 ## $bool = CLASS::haveSyslog()
175 ## + returns true if Log::Dispatch::Syslog is available
176 0 ▶sub haveSyslog {
Subroutine haveSyslog: not called CC=4 SCAR=30.0
Pod documented
177 0 ▶ return 1 if (defined($Log::Dispatch::Syslog::VERSION));
Branch: 1 branch
BranchTrueFalseTotal
if defined $Log::Dispatch::Syslog::VERSION 0 0 0
178 0 eval "use Log::Dispatch::Syslog;";
179 0 ▶ return 1 if (defined($Log::Dispatch::Syslog::VERSION) && !$@);
Branch: 1 branch
BranchTrueFalseTotal
if defined $Log::Dispatch::Syslog::VERSION and not $@ 0 0 0
Condition0%0/3
defined $Log::Dispatch::Syslog::VERSION and not $@
!ll&&!rl&&r
000
MC/DC0%0/2
defined $Log::Dispatch::Syslog::VERSION and not $@
defined $Log::Dispatch::Syslog::VERSION not $@
Truth table0%0/3
A and not(B)
A= defined $Log::Dispatch::Syslog::VERSIONB= not $@
ABresult
0X0
100
111
180 0 $@='';
181 0 return 0;
182 }
183  
184 ##==============================================================================
185 ## Functions: Initialization
186 ##==============================================================================
187  
188 ## undef = PACKAGE->logInit(%opts) ##-- use default configuration with %opts
189 ## + %opts: see defaultLogConf()
190 ## + all log calls in the DiaColloDB namespace should use a subcategory of 'DiaColloDB'
191 ## + only needs to be called once; see Log::Log4perl->initialized()
192 0 ▶sub logInit {
Subroutine logInit: not called CC=3 SCAR=24.8
Pod documented
193 0 my $that = shift;
194 0 my %opts = (%defaultLogOpts,@_);
195 0 binmode(\*STDERR,':utf8');
196 0 ▶ if (!defined($opts{l4pfile})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $opts{'l4pfile'}) { } 0 0 0
197 0 my $confstr = $that->defaultLogConf(%opts);
198 0 Log::Log4perl::init(\$confstr);
199 } else {
200 0 eval 'use Log::Dispatch::Syslog;';
201 0 eval 'use Log::Dispatch::FileRotate;';
202 0 ▶ if (defined($opts{watch})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{'watch'}) { } 0 0 0
203 0 Log::Log4perl::init_and_watch($opts{l4pfile},$opts{watch});
204 } else {
205 0 Log::Log4perl::init($opts{l4pfile});
206 }
207 }
208 #__PACKAGE__->info("initialized logging facility");
209 }
210  
211 ## undef = PACKAGE->ensureLog(@args) ##-- ensure a Log::Log4perl has been initialized
212 0 ▶sub ensureLog {
Subroutine ensureLog: not called CC=2 SCAR=17.9
Pod documented
213 0 my $that = shift;
214 0 ▶ $that->logInit(@_) if (!Log::Log4perl->initialized);
Branch: 1 branch
BranchTrueFalseTotal
if not "Log::Log4perl"->initialized 0 0 0
215 }
216  
217 ##==============================================================================
218 ## Methods: get logger
219 ##==============================================================================
220  
221 ## $logger = $class_or_obj->logger()
222 ## $logger = $class_or_obj->logger($category)
223 ## + wrapper for Log::Log4perl::get_logger($category)
224 ## + $category defaults to ref($class_or_obj)||$class_or_obj
225 0 ▶sub logger { Log::Log4perl::get_logger(ref($_[0])||$_[0]); }
Subroutine logger: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
226  
227 ##==============================================================================
228 ## Methods: messages
229 ##==============================================================================
230  
231 ## undef = $class_or_obj->trace(@msg)
232 ## + be sure you have called Log::Log4perl::init() or similar first
233 ## - e.g. DiaColloDB::Logger::logInit()
234 0 ▶sub trace { $_[0]->logger->trace(@_[1..$#_]); }
Subroutine trace: not called CC=1 SCAR=6.9
Pod documented
235 0 ▶sub debug { $_[0]->logger->debug(@_[1..$#_]); }
Subroutine debug: not called CC=1 SCAR=6.9
Pod documented
236 0 ▶sub info { $_[0]->logger->info(@_[1..$#_]); }
Subroutine info: not called CC=1 SCAR=6.9
Pod documented
237 0 ▶sub warn { $_[0]->logger->warn(@_[1..$#_]); }
Subroutine warn: not called CC=1 SCAR=6.9
Pod documented
238 0 ▶sub error { $_[0]->logger->error(@_[1..$#_]); }
Subroutine error: not called CC=1 SCAR=6.9
Pod documented
239 0 ▶sub fatal { $_[0]->logger->fatal(@_[1..$#_]); }
Subroutine fatal: not called CC=1 SCAR=6.9
Pod documented
240  
241 ## undef = $class_or_obj->llog($level, @msg)
242 ## + $level is some constant exported by Log::Log4perl::Level
243 0 ▶sub llog { $_[0]->logger->log(@_[1..$#_]); }
Subroutine llog: not called CC=1 SCAR=6.9
Pod documented
244  
245 ## undef = $class_or_obj->vlog($methodname_or_coderef_or_undef, @msg)
246 ## + calls $methodname_or_coderef_or_undef($class_or_obj,@msg) if defined
247 ## + e.g. $class_or_obj->vlog('trace', @msg)
248 0 ▶sub vlog {
Subroutine vlog: not called CC=5 SCAR=34.0
Pod documented
249 0 ▶ return if (!defined($_[1]));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[1] 0 0 0
250 0 ▶ my $sub = UNIVERSAL::isa($_[1],'CODE') ? $_[1] : (UNIVERSAL::can($_[0],$_[1]) || UNIVERSAL::can($_[0],lc($_[1])));
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($_[1], 'CODE') ? : 0 0 0
Condition0%0/3
UNIVERSAL::can($_[0], $_[1]) or UNIVERSAL::can($_[0], lc $_[1])
l!l&&r!l&&!r
000
MC/DC0%0/2
UNIVERSAL::can($_[0], $_[1]) or UNIVERSAL::can($_[0], lc $_[1])
UNIVERSAL::can($_[0], $_[1]) UNIVERSAL::can($_[0], lc $_[1])
Truth table0%0/3
A or B
A= UNIVERSAL::can($_[0], $_[1])B= UNIVERSAL::can($_[0], lc $_[1])
ABresult
1X1
011
000
251 0 ▶ return if (!defined($sub));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sub 0 0 0
252 0 return $sub->($_[0],@_[2..$#_]);
253 }
254  
255 ##==============================================================================
256 ## Methods: carp & friends
257 ##==============================================================================
258  
259 ## undef = $class_or_obj->logcroak(@msg)
260 0 ▶sub logwarn { $_[0]->logger->logwarn(@_[1..$#_]); } # warn w/o stack trace
Subroutine logwarn: not called CC=1 SCAR=6.9
Pod documented
261 0 ▶sub logcarp { $_[0]->logger->logcarp(@_[1..$#_]); } # warn w/ 1-level stack trace
Subroutine logcarp: not called CC=1 SCAR=6.9
Pod documented
262 0 ▶sub logcluck { $_[0]->logger->logcluck(@_[1..$#_]); } # warn w/ full stack trace
Subroutine logcluck: not called CC=1 SCAR=6.9
Pod documented
263  
264 0 ▶sub logdie { $_[0]->logger->logdie(@_[1..$#_]); } # die w/o stack trace
Subroutine logdie: not called CC=1 SCAR=6.9
Pod documented
265 0 ▶sub logcroak { $_[0]->logger->logcroak(@_[1..$#_]); } # die w/ 1-level stack trace
Subroutine logcroak: not called CC=1 SCAR=6.9
Pod documented
266 0 ▶sub logconfess { $_[0]->logger->logconfess(@_[1..$#_]); } # die w/ full stack trace
Subroutine logconfess: not called CC=1 SCAR=6.9
Pod documented
267  
268  
269 ##==============================================================================
270 ## Utils: Getopt::Long specification
271 ##==============================================================================
272  
273 ## %getoptLongHash = $PACKAGE->cldbLogOptions(%localOpts)
274 ## + %localOpts
275 ## verbose => $bool, ##-- if true, add 'verbose|v' as alias for 'log-level'
276 ## + adds support for logging options:
277 ## 'log-level|loglevel|ll|L=s' => \$defaultLogOpts{level},
278 ## 'log-config|logconfig|log4perl-config|l4p-config|l4p=s' => \$defaultLogOpts{l4pfile},
279 ## 'log-watch|logwatch|watch|lw=i' => \$defaultLogOpts{watch},
280 ## 'nolog-watch|nologwatch|nowatch|nolw' => sub { $defaultLogOpts{watch}=undef; },
281 ## 'log-stderr|stderr|lse!' => \$defaultLogOpts{stderr},
282 ## 'log-file|lf=s' => \$defaultLogOpts{file},
283 ## 'nolog-file|nolf' => sub { $defaultLogOpts{file}=undef; },
284 ## 'log-rotate|rotate|lr!' => \$defaultLogOpts{rotate},
285 ## 'log-syslog|syslog|ls!' => \$defaultLogOpts{syslog},
286 ## 'log-option|logopt|lo=s' => \%defaultLogOpts,
287 0 ▶sub cldbLogOptions {
Subroutine cldbLogOptions: not called CC=2 SCAR=17.9
Pod documented
288 0 my ($that,%opts) = @_;
289 return
290 (##-- Logging Options
291 0 ▶ ($opts{verbose} ? ('verbose|v=s' => sub { $defaultLogOpts{level}=uc($_[1]); }) : qw()),
Subroutine __ANON__: not called CC=1 SCAR=6.9
292 0 ▶ 'log-level|loglevel|ll|L=s' => sub { $defaultLogOpts{level}=uc($_[1]); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
293 'log-config|logconfig|log4perl-config|l4p-config|l4p=s' => \$defaultLogOpts{l4pfile},
294 'log-watch|logwatch|watch|lw=i' => \$defaultLogOpts{watch},
295 0 ▶ 'nolog-watch|nologwatch|nowatch|nolw' => sub { $defaultLogOpts{watch}=undef; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
296 'log-stderr|stderr|lse!' => \$defaultLogOpts{stderr},
297 'log-file|lf=s' => \$defaultLogOpts{file},
298 0 ▶ 'nolog-file|nolf' => sub { $defaultLogOpts{file}=undef; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
299 'log-rotate|rotate|lr!' => \$defaultLogOpts{rotate},
300 'log-syslog|syslog|ls!' => \$defaultLogOpts{syslog},
301 0 ▶ 'log-option|logopt|lo=s%' => \%defaultLogOpts,
Branch: 1 branch
BranchTrueFalseTotal
$opts{'verbose'} ? : 0 0 0
302 );
303 }
304  
305 ##==============================================================================
306 ## Utils: Profiling
307 ##==============================================================================
308  
309 ## undef = $logger->logProfile($level, $elapsed_secs, $ntoks, $nchrs)
310 0 ▶sub logProfile {
Subroutine logProfile: not called CC=1 SCAR=6.9
Pod documented
311 0 $_[0]->vlog($_[1], profile_str(@_[2..$#_]));
312 }
313  
314  
315 2 1; ##-- be happy
« DiaColloDB/Relation/TDF.pm ↑ Summary DiaColloDB/Document/TEI.pm »