From: Mike S. <msc...@ao...> - 2003-08-28 01:27:36
|
Mac Yang wrote: > I have added the support for timezone offset (the Z option). Please take > a look and let me know if you could incorporate the offset support into > the next release. Thanks! However, the algorithm you're using seems to fail on certain dates near year-end (probably because it assumes 365-days-years). Here's a script to prove it: my $time = time(); my $saved; for(my $t = $time; ; $time += 1800) { my $tz = tz($time); $saved = $tz unless defined $saved; if($tz != $saved) { print scalar localtime($time), ": $tz\n"; $saved = $tz; } } ############################################################ sub tz { ############################################################ my($time) = @_; my @g = gmtime($time); my @t = localtime($time); my $z = $t[1]-$g[1]+($t[2]-$g[2])*60+($t[7]-$g[7])*1440+ ($t[5]-$g[5])*525600; my $offset = sprintf("%+.2d%.2d", $z/60, "00"); return $offset; } __END__ It shows (here in the PST time zone): Sun Oct 26 01:13:13 2003: -0800 Sun Apr 4 03:13:13 2004: -0700 Sun Oct 31 01:13:13 2004: -0800 Fri Dec 31 16:13:13 2004: +1600 Sat Jan 1 00:13:13 2005: -0800 Sun Apr 3 03:13:13 2005: -0700 Would be great if you could look into that. > On a separate thread, is it safe to use log4perl (with FileRotate > appender) with a program that forks subprocesses (log4perl are called > from both the parent and children processes)? Does log4perl performs any > sort of file locking? There was a similar question posted to the > log4j-user list about a month ago, but no answer so far. Log4perl's file appender doesn't obtain a lock to the file it writes to, so spawning several processes with file appenders writing to the same file will mangle your log lines (and probably cause additional problems with the rotating file appender). However, you could write a locking file appender to avoid that. Or just have each child log to a different file. Let me know what you find out about that timezone problem, I'm definitely interested in adding your contribution to the distribution. -- Mike Mike Schilli log...@pe... |