Log::Localized

Log::Localized is a Perl module to localize your logging.
Download

Log::Localized Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Erwan Lemonnier
  • Publisher web site:
  • http://search.cpan.org/~erwan/Sub-Contract-0.09/lib/Sub/Contract.pm

Log::Localized Tags


Log::Localized Description

Log::Localized is a Perl module to localize your logging. Log::Localized is a Perl module to localize your logging.SYNOPSISWhat you most probably want to do is something like: package Foo; use Log::Localized; sub bar { # this message will be displayed if method bar's verbosity is >= 1 llog(1,"running bar()"); } # this message will be displayed if package Foo's verbosity is >= 3 llog(3,"loaded package Foo");Then paste the following local verbosity rules in a file called 'verbosity.conf', in the same directory as your program: # log everything from wherever inside Foo and its subclasses, up to level 3 Foo:: = 3 # except for function Foo::foo who shall have verbosity 0 Foo::bar = 0SYNOPSIS - ADVANCEDIn a program accepting command line arguments, you may want to do: use Getopt::Long; use Log::Localized log => 1; GetOptions("verbose|v+" => sub { $Log::Localized::VERBOSITY++; } ); llog(1,"you used -v"); llog(2,"you used -v -v");You may alter local verbosity from within the running code: package Foo; use Log::Localized log => 1; # verbosity level is 0 by default { # set verbosity locally in this block local $Log::Debug::VERBOSITY = 5; llog(5,"this will be logged"); } debug(5,"but this won't");If you want to import 'llog' under another name in the calling module: package Foo; use Log::Localized rename => "my_log"; # call Log::Localized::llog() my_log(1,"renamed llog()");See the examples directory in the module distribution for more real life examples.Log::Localized provides you with an interface for defining dynamically exactly which part of your code should log messages and with which verbosity.Log::Localized addresses one issue of traditional logging: in very large systems, a slight increase in logging verbosity usually generates insane amounts of logs. Hence the need of being able to turn on verbosity selectively in some areas of code only, in a localized way.Log::Localized is based on the concept of local verbosity. Each package and each function in a package has its own local verbosity, set to 0 by default. With Log::Localized you can change the local verbosity in just a function, just a package or just a class hierarchy via a so called verbosity rule. Verbosity rules are passed to Log::Localized either via a configuration file or via an import parameter. By changing verbosity rules according to the needs of the moment, you can alter your program's logging flow in a very fine-grained way, and get logs from only the code areas you are interested in.Log::Localized comes with default settings that make it usable 'out of the box', but its configuration options will let you redefine pretty much everything in its behavior.The actual logging in Log::Localized is handled by Log::Dispatch.Requirements:· Perl Requirements: · Perl


Log::Localized Related Software