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