| Sprocket documentation | Contained in the Sprocket distribution. |
Sprocket::Logger::Basic - Basic logging for Sprocket
my $log = Sprocket::Logger::Basic->new(); $log->put( $server, { v => 4, msg => 'Hello world' } );
Sprocket::Logger::Basic logs to STDERR and
$sprocket_component is either a client or server object. This will write a log line out to STDERR.
David Davis <xantus@cpan.org>
Copyright 2006-2007 by David Davis
Same as Perl, see the LICENSE file
| Sprocket documentation | Contained in the Sprocket distribution. |
package Sprocket::Logger::Basic; use strict; use warnings; sub new { my $class = shift; bless( {}, ref $class || $class ); } sub put { my ($self, $sprocket, $opts) = @_; return unless ( $opts->{v} <= $sprocket->{opts}->{log_level} ); my $con = $sprocket->{heap}; my $sender = ( $con ) ? ( $con->peer_addr ? $con->peer_addr : '' )."(".$con->ID.")" : "?"; my $l = $opts->{l} ? $opts->{l}+2 : 2; my $caller = $opts->{call} ? $opts->{call} : ( caller($l) )[3] || '?'; $caller =~ s/^POE::Component/PoCo/o; $caller =~ s/^Sprocket::Plugin/SPlugin/o; print STDERR '['.localtime()."][pid:$$][$sprocket->{connections}][$caller][$sender] $opts->{msg}\n"; } 1; __END__