Steven Haryanto > Log-Any-For-Class-0.23 > Log::Any::For::Package

Download:
Log-Any-For-Class-0.23.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.23   Source  

NAME ^

Log::Any::For::Package - Add logging to package

VERSION ^

version 0.23

SYNOPSIS ^

Add log to some existing packages (in other words, modules that are already loaded):

 use Foo;
 use Bar;
 use Log::Any::For::Package qw(Foo Bar);
 ...

Now calls to your module functions are logged, by default at level 'trace'. To see the logs, use e.g. Log::Any::App in command-line:

 % TRACE=1 perl -MLog::Any::App -MFoo -MBar -MLog::Any::For::Package=Foo,Bar \
     -e'Foo::func(1, 2, 3)'
 ---> Foo::func([1, 2, 3])
  ---> Bar::nested()
  <--- Bar::nested()
 <--- Foo::func() = 'result'

Use add_logging_to_package() which gives more options, e.g. to add log to multiple packages specified by regex:

 use Log::Any::For::Package qw(add_logging_to_package);
 add_logging_to_package(packages => [qw/Foo::.*/]);

To install an import (@INC) hook so that subsequent modules loaded will be logged:

 add_logging_to_package(packages => [...], import_hook=>1);

or, via import:

 % TRACE=1 perl -MLog::Any::App -MLog::Any::For::Package=-hook,1,.* ...

FUNCTIONS ^

add_logging_to_package(%args) -> any

Add logging to package.

Logging will be done using Log::Any.

Currently this function adds logging around function calls, e.g.:

    ---> Package::func(ARGS)
    <--- Package::func() = RESULT
    ...

Arguments ('*' denotes required arguments):

Return value:

FAQ ^

How do I know that logging has been added to a package?

Log::Any::For::Package logs a trace statement like this after it added logging to a package:

 Added logging to package Foo (subs ["sub1","sub2",...])

If you use Log::Any::App to enable logging, you might not see this log message because it is produced during compile-time after use Foo. To see this statement, you can do require Foo instead or setup the logging at compile-time yourself instead of at the init-phase like what Log::Any::App is doing.

ENVIRONMENT ^

LOG_PACKAGE_INCLUDE_SUB_RE (str)

LOG_PACKAGE_EXCLUDE_SUB_RE (str)

LOG_SUB_ARGS (bool)

LOG_SUB_RESULT (bool)

CREDITS ^

Some code portion taken from Devel::TraceMethods.

SEE ALSO ^

Log::Any::For::Class

For some modules, use the appropriate Log::Any::For::*, for example: Log::Any::For::DBI, Log::Any::For::LWP.

HOMEPAGE ^

Please visit the project's homepage at https://metacpan.org/release/Log-Any-For-Class.

SOURCE ^

Source repository is at https://github.com/sharyanto/perl-Log-Any-For-Class.

BUGS ^

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Log-Any-For-Class

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR ^

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2013 by Steven Haryanto.

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

syntax highlighting: