Philip Gwyn > POE-XUL > POE::XUL::Logging

Download:
POE-XUL-0.0600.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.0600   Source  

NAME ^

POE::XUL::Logging - POE::XUL logging

SYNOPSIS ^

    use POE::Component::XUL;
    use POE::Logging;

    POE::Component::XUL->spawn( { logging => $destination } );

    xlog "I'm doing X";
    xwarn "Look at me!"
    xcarp "You did that!";
    xdebug "Something=$something";

DESCRIPTION ^

POE::XUL::Logging is a singleton object used by POE::XUL to flexibly dispatch log messages, warnings and debug messages in an application-defined manner. The message destination may be a coderef, a logging object (think Log4Perl), a POE session or POE session/event tuple.

An application does not instanciate the POE::XUL::Logging singleton directly. Rather, this is handled by POE::Component::XUL and controled by the logging parameter to "spawn" in POE::Component::XUL.

Each message has a severity level. POE::XUL::Logging defines the following levels, in order of severity: DEBUG, LOG, REQ, WARN. REQ and LOG are synonyms, the difference being that REQ is for logging a static request, equivalent to apache's access_log.

There is also the SETUP psuedo-level which is used when it is time to open or reopen any log files.

CONFIG ^

POE::XUL::Logging is configured by a logger parameter that is passed to POE::Component::XUL's spawn method.

$message

Regardless of the logger being used, each message is encapsulated in a message structure. This structure is a hashref with the following keys:

type

One of DEBUG, LOG, REQ, WARN or SETUP. A logger is expected to handle the message bassed on this field. DEBUG and WARN messages might ignored in a production server. REQ messages might go to a different file then LOG. SETUP messages are used by POE::Component::XUL to tell the logger to open (or reopen) any log files.

message

Text of the message.

caller

Arrayref of the output of "caller" in perlfunc at the relevant caller-frame-level.

A logger may be one of the following:

coderef

    POE::Component::XUL->spawn( { logging => \&my_log } );
    sub my_log {
        my( $message ) = @_;
    }

$message is described above.

object

    my $logger = Log::Log4perl->get_logger( "My::Logger" );
    POE::Component::XUL->spawn( { logging => $logger } );

All log messages will be dispatched via the object's log method:

    sub log {
        my( $level, $message ) = @_;
    }

$level is the numeric level, compatible with Log::Log4perl. $message is described above.

Note that the object will never be passed a SETUP message.

POE session

    POE::Component::XUL->spawn( { logging => $_[SESSION]->id } );

All log messages will be dispatched via the sessions's log event:

    sub log {
        my( $self, $message ) = @_[OBJECT, ARG0];
    }

$message is described above.

POE session/method tuple

    POE::Component::XUL->spawn( { logging => [ $session, $event ] );

All log messages will be dispatched to $session's $event state.

    sub log_state {
        my( $heap, $message ) = @_[HEAP, ARG0];
    }

$message is described above.

FUNCTIONS ^

xlog

    xlog "Foo", $biff, " bar";

xwarn

    xwarn "This is going badly";

xcarp

    xcarp "Don't do that";

Same as "xwarn", but caller is one frame higher.

xdebug

    xdebug "Do you care";

AUTHOR ^

Philip Gwyn <gwyn-at-cpan.org>

CREDITS ^

Based on XUL::Node by Ran Eilam.

COPYRIGHT AND LICENSE ^

Copyright 2007-2010 by Philip Gwyn. All rights reserved;

Copyright 2003-2004 Ran Eilam. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO ^

perl(1), POE::XUL, POE::XUL::Node.

syntax highlighting: