Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Singleton logger

Thread Tools

Singleton logger

Posts: n/a

I need a GL::Logger wich implements Class::Singleton
to be a singleton and Log::Log4perl to can log amy
message into a file. Here is the module source:
package GL::Logger;

use Class::Singleton;
use vars qw( $ERROR );
@ISA = qw(Class::Singleton);
use Log::Log4perl;
my $ERROR = '';
my $logger;

sub instance(){
my $class = shift;
my $self = bless { }, $class;
unless (defined ($self->{ $logger } = Log::Log4perl->get_logger('...'))) {
$ERROR = "Cannot get configuration file (log4perl.conf)\n";
return undef;

sub log(){
my($level, $msg) = @_;
if($level eq 'DEBUG'){
if($level eq 'INFO'){
if($level eq 'WARN'){
if($level eq 'ERROR'){
if($level eq 'FATAL'){
return 0;

And this is the way how I want to use it:

#!perl -w
use GL::Logger;
my $logger = GL::Logger->instance();
$logger->log("ERROR", "blablabla");

It retunr the following error message:

Use of uninitialized value in hash element at c:/Perl/site/lib/GL/ line 14.

What is wrong ?
Laszlo Graf
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Singleton - Whether Cloneable overrides Singleton Proton Projects - Moin Java 4 03-27-2007 02:59 AM
Singleton classes and Singleton pattern Wilhelm Ruby 1 10-11-2006 01:08 PM
Ruby's Logger vs ActiveRecord: no more Logger data output Georges Ko Ruby 4 07-26-2006 01:38 PM
why do i need to use org/apache/avalon/framework/logger/Logger to convert XSL-FO to PDF?? sachin XML 1 02-03-2006 09:58 PM
ruby's Logger conflict with Log4r's Logger cap Ruby 3 12-11-2005 03:44 PM