bowei_99 has asked for the wisdom of the Perl Monks concerning the following question:
|
use Log::StdLog { file => $filename };
Normally, Log::StdLog logs messages to a file named "$0.log" (that is, the current filename with .log appended. But if you pass a 'file' option, it uses that file as its logfile instead. |
However, this only works if I specify the filename as $0.log and not $filename.
I found what I thought might have been the answer at the CPAN RT page for Log::Std, where someone posted a test script with the following code:
where the second option is commented out because it doesn't work (but it's what I want). Similarly, I tried using the following code suggested as a workaround on that same page:use Log::StdLog { file => "$0.log" }; # OK #use Log::StdLog { file => $filename }; # NOT OK
Although this is what I want, it only works if you don't specify use strict; use warnings;. And, of course, I have these in my code, and want to stick with them.use Log::StdLog; # at compile time my $file = "$config{dir}". basename($0) .".log.$$"; # at run time my $level = 'warn'; # specify file at runtime (below). Log::StdLog->import ({ level => $level, file => $file } ); # works, ru +ntime
Doing a Supersearch and google turned up nothing that I haven't already seen. Anybody ran into this before or have any thoughts as to how I can pass in a filename?
-- Burvil
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing filename to Log::Std
by borisz (Canon) on Apr 12, 2006 at 20:04 UTC | |
by bowei_99 (Friar) on Apr 12, 2006 at 21:40 UTC | |
by chromatic (Archbishop) on Apr 12, 2006 at 21:51 UTC | |
by borisz (Canon) on Apr 12, 2006 at 21:47 UTC | |
by bowei_99 (Friar) on Apr 12, 2006 at 22:33 UTC | |
|
Re: Passing filename to Log::Std
by bowei_99 (Friar) on Apr 12, 2006 at 22:57 UTC |