1 |
package Torus::Logger; |
2 |
|
3 |
use strict; |
4 |
use warnings; |
5 |
|
6 |
#require "$basepath/etc/log/Config.pm"; |
7 |
#BEGIN { |
8 |
use FindBin qw($Bin); |
9 |
#require "$Bin/use_libs.pl"; |
10 |
#} |
11 |
|
12 |
|
13 |
use Log::Dispatch::Configurator::Hardwired; |
14 |
use Log::Dispatch::Config; |
15 |
|
16 |
my $bool_quiet = grep /--quiet/, @ARGV; |
17 |
my $bool_debug = grep /--debug/, @ARGV; |
18 |
my $bool_verbose = grep /--verbose/, @ARGV; |
19 |
configureLogDispatcher( { quiet => $bool_quiet, debug => $bool_debug, verbose => $bool_verbose } ); |
20 |
|
21 |
sub configureLogDispatcher { |
22 |
my $args = shift; |
23 |
my $logHandlerMeta = Log::Dispatch::Configurator::Hardwired->new(); |
24 |
# configure custom logHandler |
25 |
#$logHandlerMeta->{file_filename} = "$basepath/var/log/logfile.txt"; |
26 |
$logHandlerMeta->{file_filename} = "$Bin/../var/log/logfile.txt"; |
27 |
$logHandlerMeta->{screen_min_level} = 'info'; |
28 |
|
29 |
if ($args->{quiet}) { |
30 |
$logHandlerMeta->{screen_min_level} = 8; |
31 |
} |
32 |
|
33 |
if ($args->{debug}) { |
34 |
$logHandlerMeta->{screen_min_level} = 'debug'; |
35 |
} |
36 |
|
37 |
if ($args->{verbose}) { |
38 |
$logHandlerMeta->{verbose} = 1; |
39 |
} |
40 |
|
41 |
Log::Dispatch::Config->configure($logHandlerMeta); |
42 |
} |
43 |
|
44 |
1; |