Sprocket::Logger::Basic - Basic logging for Sprocket


Sprocket documentation Contained in the Sprocket distribution.

Index


Code Index:

NAME

Top

Sprocket::Logger::Basic - Basic logging for Sprocket

SYNOPSIS

Top

my $log = Sprocket::Logger::Basic->new(); $log->put( $server, { v => 4, msg => 'Hello world' } );

ABSTRACT

Top

Sprocket::Logger::Basic logs to STDERR and

METHODS

Top

put( $sprocket_component => { v => $log_level, msg => $log_msg } );

$sprocket_component is either a client or server object. This will write a log line out to STDERR.

SEE ALSO

Top

Sprocket

AUTHOR

Top

David Davis <xantus@cpan.org>

COPYRIGHT AND LICENSE

Top


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__