GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  LOG::ANY::PROXY (3)

.ds Aq ’

NAME

Log::Any::Proxy - Log::Any generator proxy object

CONTENTS

VERSION

version 1.032

SYNOPSIS



    # prefix log messages
    use Log::Any $log, prefix => MyApp: ;

    # transform log messages
    use Log::Any $log, filter => \&myfilter;

    # format with String::Flogger instead of the default
    use String::Flogger;
    use Log::Any $log, formatter => sub {
        my ($cat, $lvl, @args) = @_;
        String::Flogger::flog( @args );
    };



DESCRIPTION

Log::Any::Proxy objects are what modules use to produce log messages. They construct messages and pass them along to a configured adapter.

USAGE

    Simple logging

Your library can do simple logging using logging methods corresponding to the log levels (or aliases):
o trace
o debug
o info (inform)
o notice
o warning (warn)
o error (err)
o critical (crit, fatal)
o alert
o emergency
Pass a string to be logged. Do not include a newline.



    $log->info("Got some new for you.");



The log string will be tranformed via the filter attribute (if any) and the prefix (if any) will be prepended.

<B>NOTEB>: While you are encouraged to pass a single string to be logged, if multiple arguments are passed, they are concatenated with a space character into a single string before processing. This ensures consistency across adapters, some of which may support multiple arguments to their logging functions (and which concatenate in different ways) and some of which do not.

    Advanced logging

Your library can do advanced logging using logging methods corresponding to the log levels (or aliases), but with an f appended:
o tracef
o debugf
o infof (informf)
o noticef
o warningf (warnf)
o errorf (errf)
o criticalf (critf, fatalf)
o alertf
o emergencyf
When these methods are called, the adapter is first checked to see if it is logging at that level. If not, the method returns without logging.

Next, arguments are transformed to a message string via the formatter attribute. The default acts like sprintf with some helpful formatting.

Finally, the message string is logged via the simple logging functions, which can transform or prefix as described above.

ATTRIBUTES

    adapter

A Log::Any::Adapter object to receive any messages logged. This is generated by Log::Any and can not be overridden.

    category

The category name of the proxy. If not provided, Log::Any will set it equal to the calling when the proxy is constructed.

    filter

A code reference to transform messages before passing them to a Log::Any::Adapter. It gets three arguments: a category, a numeric level and a string. It should return a string to be logged.



    sub {
        my ($cat, $lvl, $msg) = @_;
        return "[$lvl] $msg";
    }



If the return value is undef or the empty string, no message will be logged. Otherwise, the return value is passed to the logging adapter.

Numeric levels range from 0 (emergency) to 8 (trace). Constant functions for these levels are available from Log::Any::Adapter::Util.

    formatter

A code reference to format messages given to the *f methods (tracef, debugf, infof, etc..)

It get three or more arguments: a category, a numeric level and the list of arguments passsed to the *f method. It should return a string to be logged.



    sub {
        my ($cat, $lvl, $format, @args) = @_;
        return sprintf($format, @args);
    }



The default formatter acts like sprintf, except that undef arguments are changed to <undef> and any references or objects are dumped via Data::Dumper (but without newlines).

Numeric levels range from 0 (emergency) to 8 (trace). Constant functions for these levels are available from Log::Any::Adapter::Util.

    prefix

If defined, this string will be prepended to all messages. It will not include a trailing space, so add that yourself if you want. This is less flexible/powerful than filter, but avoids an extra function call.

AUTHORS

o Jonathan Swartz <swartz@pobox.com>
o David Golden <dagolden@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Jonathan Swartz and David Golden.

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

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 LOG::ANY::PROXY (3) 2015-03-26

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.