[Bps-public-commit] r10223 - bpsbuilder/BPB/lib/BPB

sunnavy at bestpractical.com sunnavy at bestpractical.com
Wed Jan 2 11:39:38 EST 2008


Author: sunnavy
Date: Wed Jan  2 11:39:26 2008
New Revision: 10223

Added:
   bpsbuilder/BPB/lib/BPB/Logger.pm

Log:
added logger

Added: bpsbuilder/BPB/lib/BPB/Logger.pm
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/lib/BPB/Logger.pm	Wed Jan  2 11:39:26 2008
@@ -0,0 +1,89 @@
+package BPB::Logger;
+use strict;
+use warnings;
+use Carp;
+use Log::Log4perl;
+
+sub new {
+    my $class = shift;
+    my $bpb   = shift;
+
+    my $self = {};
+    bless $self, $class;
+
+    if ( not Log::Log4perl->initialized ) {
+        $class->_initialize_log4perl($bpb);
+    }
+    return $self;
+}
+
+sub _initialize_log4perl {
+    my $class = shift;
+    my $bpb   = shift;
+
+    my $log_config = $bpb->config->name->{'log'}{config};
+
+    if ( $log_config && -r $log_config ) {
+        Log::Log4perl->init($log_config);
+    }
+    else {
+        my $log_level = uc $bpb->config->name->{'log'}{level} || 'INFO';
+        my %default = (
+            'log4perl.rootLogger'      => "$log_level,Screen",
+            'log4perl.appender.Screen' => 'Log::Log4perl::Appender::Screen',
+            'log4perl.appender.Screen.stderr' => 1,
+            'log4perl.appender.Screen.layout' =>
+              'Log::Log4perl::Layout::SimpleLayout'
+        );
+        Log::Log4perl->init( \%default );
+    }
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+BPB::Logger - 
+
+
+=head1 SYNOPSIS
+
+    use BPB::Logger;
+
+=head1 DESCRIPTION
+
+
+=head1 INTERFACE
+
+
+
+=head1 DEPENDENCIES
+
+
+None.
+
+
+=head1 INCOMPATIBILITIES
+
+None reported.
+
+
+=head1 BUGS AND LIMITATIONS
+
+No bugs have been reported.
+
+=head1 AUTHOR
+
+sunnavy  C<< <sunnavy at bestpractical.com> >>
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright 2007 Best Practical Solutions.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+



More information about the Bps-public-commit mailing list