From e994aafb443b8550f0241991d3905eb631199e84 Mon Sep 17 00:00:00 2001 From: Ricardo Signes Date: Thu, 7 Apr 2011 23:16:39 -0400 Subject: [PATCH] add log_file and log_path --- Changes | 1 + lib/Log/Dispatchouli.pm | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 560796f..5841c3c 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for {{$dist->name}} {{$NEXT}} + add log_file and log_path options 2.004 2011-01-21 15:52:41 America/New_York BUG FIX: it is okay to replace the default logger, always diff --git a/lib/Log/Dispatchouli.pm b/lib/Log/Dispatchouli.pm index 15b962a..bf0f61a 100644 --- a/lib/Log/Dispatchouli.pm +++ b/lib/Log/Dispatchouli.pm @@ -100,10 +100,15 @@ Valid arguments are: ident - the name of the thing logging (mandatory) to_self - log to the logger object for testing; default: false - to_file - log to PROGRAM_NAME.YYYYMMDD in the log path; default: false to_stdout - log to STDOUT; default: false to_stderr - log to STDERR; default: false facility - to which syslog facility to send logs; default: none + + to_file - log to PROGRAM_NAME.YYYYMMDD in the log path; default: false + log_file - a leaf name for the file to log to with to_file + log_path - path in which to log to file; defaults to DISPATCHOULI_PATH + environment variable or, failing that, to your system's tmpdir + log_pid - if true, prefix all log entries with the pid; default: true fail_fatal - a boolean; if true, failure to log is fatal; default: true muted - a boolean; if true, only fatals are logged; default: false @@ -149,8 +154,8 @@ sub new { if ($arg->{to_file}) { require Log::Dispatch::File; my $log_file = File::Spec->catfile( - ($self->env_value('PATH') || File::Spec->tmpdir), - sprintf('%s.%04u%02u%02u', + ($arg->{log_path} || $self->env_value('PATH') || File::Spec->tmpdir), + $arg->{log_file} || sprintf('%s.%04u%02u%02u', $ident, ((localtime)[5] + 1900), sprintf('%02d', (localtime)[4] + 1),