145 | 145 |
if ($arg->{to_file}) {
|
146 | 146 |
require Log::Dispatch::File;
|
147 | 147 |
my $log_file = File::Spec->catfile(
|
148 | |
($ENV{DISPATCHOULI_PATH} || File::Spec->tmpdir),
|
|
148 |
($self->env_value('PATH') || File::Spec->tmpdir),
|
149 | 149 |
sprintf('%s.%04u%02u%02u',
|
150 | 150 |
$ident,
|
151 | 151 |
((localtime)[5] + 1900),
|
|
169 | 169 |
);
|
170 | 170 |
}
|
171 | 171 |
|
172 | |
if ($arg->{facility} and not $ENV{DISPATCHOULI_NOSYSLOG}) {
|
|
172 |
if ($arg->{facility} and not $self->env_value('NOSYSLOG')) {
|
173 | 173 |
require Log::Dispatch::Syslog;
|
174 | 174 |
$log->add(
|
175 | 175 |
Log::Dispatch::Syslog->new(
|
|
221 | 221 |
|
222 | 222 |
$self->{debug} = exists $arg->{debug}
|
223 | 223 |
? ($arg->{debug} ? 1 : 0)
|
224 | |
: ($ENV{DISPATCHOULI_DEBUG} ? 1 : 0);
|
|
224 |
: ($self->env_value('DEBUG') ? 1 : 0);
|
225 | 225 |
|
226 | 226 |
$self->{fail_fatal} = exists $arg->{fail_fatal} ? $arg->{fail_fatal} : 1;
|
227 | 227 |
|
|
439 | 439 |
=cut
|
440 | 440 |
|
441 | 441 |
sub string_flogger { 'String::Flogger' }
|
|
442 |
|
|
443 |
=head2 env_prefix
|
|
444 |
|
|
445 |
This method should return a string used as a prefix to find environment
|
|
446 |
variables that affect the logger's behavior. For example, if this method
|
|
447 |
returns C<XYZZY> then when checking the environment for a default value for the
|
|
448 |
C<debug> parameter, Log::Dispatchouli will first check C<XYZZY_DEBUG>, then
|
|
449 |
C<DISPATCHOULI_DEBUG>.
|
|
450 |
|
|
451 |
By default, this method returns C<()>, which means no extra environment
|
|
452 |
variable is checked.
|
|
453 |
|
|
454 |
=cut
|
|
455 |
|
|
456 |
sub env_prefix { return; }
|
|
457 |
|
|
458 |
=head2 env_value
|
|
459 |
|
|
460 |
my $value = $logger->env_value('DEBUG');
|
|
461 |
|
|
462 |
This method returns the value for the environment variable suffix given. For
|
|
463 |
example, the example given, calling with C<DEBUG> will check
|
|
464 |
C<DISPATCHOULI_DEBUG>.
|
|
465 |
|
|
466 |
=cut
|
|
467 |
|
|
468 |
sub env_value {
|
|
469 |
my ($self, $suffix) = @_;
|
|
470 |
|
|
471 |
my @path = grep { defined } ($self->env_prefix, 'DISPATCHOULI');
|
|
472 |
|
|
473 |
for my $prefix (@path) {
|
|
474 |
my $name = join q{_}, $prefix, $suffix;
|
|
475 |
return $ENV{ $name } if defined $ENV{ $name };
|
|
476 |
}
|
|
477 |
|
|
478 |
return;
|
|
479 |
}
|
442 | 480 |
|
443 | 481 |
=head1 METHODS FOR TESTING
|
444 | 482 |
|