The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

TITLE

Log::Selective - Selectively choose what to log

SYNOPSIS

        use Log::Selective;
        Log::Selective::select(:tagA, :main);
        note "I'm here", :tagA;                 # prints "I'm here at somefile.pl line 3."
        note "Now I'm here", :tagB;             # doesn't print, tagB isn't active
        note "And here too!";                   # Implicit tag 'main', is printed

DESCRIPTION

Log::Selective is a Perl 6 module for printing simple log messages to $ERR. It allows sets of messages to be selected by use of tags; messages whose tags haven't been selected won't be printed. It is designed for so-called "print-based debugging", but can be put to other uses as well.

Log::Selective exports a single function, note, which is called with zero or more strings, followed by zero or more tags. The strings are printed to $ERR only if one or more of the tags have been "selected", either by giving them to the unexported Log::Selective::select function or by including them in the SELECT_LOGS environment variable. There is no facility to deselect a tag.

Tags

A tag is always represented by a named parameter (pair). (The value of the pair is currently unused, but for forward compatibility it should always be the value 1, the default for the :name form.) By convention, tags are lowercase.

If note is not provided with any tags, it will intuit one by extracting the last component of the calling function's package name. (For example, if a function in Some::Module called note without providing any tags, it would look for a tag named Module.) Since module names are typically capitalized, most "autotags" will be too.

When activated, the special tag :all will cause all tracing messages to be printed, even if none of their tags match.

BUGS

None known. Report any to the author; patches are always appreciated.

COPYRIGHT

Copyright (C) 2005 Brent Royal-Gordon <brent@brentdax.com>. All Rights Reserved.

This program is Free Software, and may be used, distributed and modified under the same terms as Perl itself.