diff --git a/plugins/logging/file b/plugins/logging/file index 1dcdf28..a6c445e 100644 --- a/plugins/logging/file +++ b/plugins/logging/file @@ -17,13 +17,14 @@ configuration file: =over -logging/file [loglevel I] [reopen] [nosplit] I +logging/file [loglevel I] [reopen] [nosplit] [tsformat I] I For example: logging/file loglevel LOGINFO /var/log/qpsmtpd.log logging/file /var/log/qpsmtpd.log.%Y-%m-%d logging/file loglevel LOGCRIT reopen |/usr/local/sbin/page-sysadmin +logging/file loglevel LOGDEBUG tsformat %FT%T /var/log/qpsmtpd.log =back @@ -68,6 +69,12 @@ given should be chosen from the list below. Priorities count downward (for example, if LOGWARN were selected, LOGERROR, LOGCRIT and LOGEMERG messages would be logged as well). +=item tsformat I + +By default qpsmtpd will prepend log items with the date and time as given in +the format by perl's C function. If you prefer another format then +you can specify a tsformat parameter. + =over =item B @@ -121,6 +128,7 @@ sub register { my %args; $self->{_loglevel} = LOGWARN; + $self->{_tsformat} = '%a %b %d %T %Y'; # same as scalar localtime while (1) { last if !@args; @@ -147,6 +155,11 @@ sub register { shift @args; $self->{_reopen} = 1; } + elsif (lc $args[0] eq 'tsformat') { + shift @args; + my $format = shift @args; + $self->{_tsformat} = $format; + } else { last } } @@ -260,7 +273,8 @@ sub hook_logging { } my $f = $self->{_f}; - print $f scalar localtime, ' ', hostname(), '[', $$, ']: ', @log, "\n"; + print $f strftime($self->{_tsformat}, localtime), ' ', + hostname(), '[', $$, ']: ', @log, "\n"; return DECLINED; }