queeg has asked for the wisdom of the Perl Monks concerning the following question:
I have a large project consisting of cron jobs and cgis that do some screen scrapes. Life became unmanagebale - cutting, pasting, and dying over and over again. I finally turned to OOP. I barely know my $self, but it is beautiful. Wait till I discover my inheritance.
I'm now turning to Log4perl and log4perl conf files to clean up my mess of "print 'foo' if's," and rewriting my .pl's and .cgi's to use my module 'EZ::Emulate.pm.' I want Emulate.pm's logging behavior to be determined by the Log4perl conf file of the program calling on Emulate.pm.
I currently have it working with this in main:
and in Emulate.pm with: $main::logger->info('Bar');my $log_conf = './log.fifo.conf'; use Log::Log4perl qw(get_logger :levels); Log::Log4perl->init("$log_conf"); our $logger = get_logger(); $logger->info('Foo');
However, having the name of a main package variable hard coded in the module just feels... dirty.
Should I instead be doing something like this in main:
and then in Emulate.pm use "use Log4perl" and create loggers in the EZ::Emulate namespace, or should I be approaching this differently?use EZ::Emulate; $EZ::Emulate::log_conf = $log_conf;
I'd really rather do this right the second time instead of the third, and I'm not sure that I'm not missing something simple here. Any suggestions?
Thanks,
Queeg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Log4perl with my module
by adrianh (Chancellor) on Dec 30, 2005 at 00:57 UTC | |
by queeg (Novice) on Dec 31, 2005 at 06:27 UTC |