NAME

    Log::Simple - A simple but featureful logging mechanism.

SYNOPSIS

        use Log::Simple;
    
        my $log = Log::Simple->new(name => 'whatever'); # name is optional
    
        $log->warning("default level (4)");
    
        $log->_4("all levels can be called by number. This is warning()");
    
        $log->_7("this is debug(). Default level is 4, so this won't print");
    
        $log->level(7);
        $log->debug("same as _7(). It'll print now");
    
        $log->file('file.log');
        $log->info("this will go to file");
        $log->file(0); # back to STDOUT
    
        $log->_6("info facility, example output");
        #[2016-03-17 16:49:32.491][info][whatever] info facility, example output
    
        $log->display(0);
        $log->info("display(0) disables all output but this msg");
        $log->info("see display() method for disabling, enabling individual tags");
    
        $log->display(1);
        $log->info("all tags enabled");
        #[2016-03-17 16:52:06.356][info][whatever][5689][t/syn.pl|29] all tags enabled
    
        $log->print(0);
        my $log_entry = $log->info("print(0) disables printing and returns the entry");

DESCRIPTION

    *** This is the first public release. The POD may be off a bit, and
    despite extensive CI testing on multiple platforms, there still may be
    a few small issues. ***

    Lightweight (core-only) and very simple yet powerful debug tool for
    printing or writing to file log type entries based on a configurable
    level (0-7).

    It provides the ability to programmatically change which output tags to
    display, provides numbered methods so you don't have to remember the
    name to number level translation, provides the ability to create
    descendent children, easily enable/disable file output, levels, display
    etc.

 Log entry format

    By default, log entries appear as such, with a timestamp, the name of
    the facility, the name (if specified in the constructor) and finally
    the actual log entry message.

        [2016-03-17 17:01:21.959][info][whatever] info facility, example output

    All of the above tags can be enabled/disabled programatically at any
    time, and there are others that are not enabled by default. See display
    method for details.

 Levels

    Verbosity and associated levels are:

    level 0, 'emergency|emerg' =item level 1, 'alert' =item level 2,
    'critical|crit' =item level 3, 'error|err' =item level 4,
    'warning|warn' =item level 5, 'notice' =item level 6, 'info' =item
    level 7, 'debug'

    Note that all named level methods have an associated _N method, so you
    don't have to remember the names at all. Using the numbers is often
    much easier.

    Setting the level will display all messages related to that level and
    below.

METHODS

 new(%args)

    Builds and returns a new Log::Simple object. All arguments are
    optional, and they can all be set using accessor methods after
    instantiation. These params are:

  name

    Default: undef

    Specify a name for your log object. It will be displayed by default in
    the log output. The name of your program or module is a good choice.

  level => Integer

    Default: 4

    Specify the name or equivalent number (0-7) of the highest level to
    log. Note that this can be set in a LS_LEVEL environment variable (and
    changed while your program is running).

  file => String

    Default: undef

    The name of a file to write log entries into. By default, we print to
    STDOUT.

  write_mode => Bool

    Default: 'a' (append)

    By default, we append to the chosen log file. Send in 'w' or 'write' to
    overwrite instead.

  print => Bool

    Default: 1 (enabled)

    If a false value is sent in (ie. 0), we'll disable printing the log
    entries, and return them as a string value instead on each call.

  display => Bool

    Default: enabled

    Send in a false value to disable all log entry tags, less the actual
    message. See display() in METHODS to learn how to enable and disable
    individual tags.

 level(Ingeger)

    Set and return the facility level. Will return the current value with a
    param sent in or not. It can be changed at any time. Note that you can
    set this with the LS_LEVEL environment variable, at any time. the next
    method call regardless of what it is will set it appropriately.

 file('file.log', 'mode')

    By default, we write to STDOUT. Send in the name of a file to write
    there instead. Mode is optional; we'll append to the file by default.
    Send in 'w' or 'write' to overwrite the file.

 display(HASH|Bool)

    List of log entry tags, and default printing status: name => 1,
    #specified in new() or name() time => 1, label => 1, # the string value
    of the level being called pid => 0, # process ID proc => 0, #
    "filename|line number" of the caller

    In HASH param mode, send in any or all of the tags with 1 (enable) or 0
    (disable).

    You can also send in 1 to enable all of the tags, or 0 to disable them
    all.

 print(Bool)

    Default is enabled. If disabled, we won't print at all, and instead,
    return the log entry as a scalar string value.

 child('name')

    This method will create a clone of the existing Log::Simple object, and
    then concatenate the parent's name with the optional name sent in here
    for easy identification in the logs.

    All settings employed by the parent will be used in the child, unless
    explicity changed via the methods.

    In a module or project, you can create a top-level log object, then in
    all subs, create a child with the sub's name to easily identify flow
    within the log. In an OO project, stuff the parent log into the main
    object, and clone it from there.

LOGGING METHODS

 emergency

    Level 0

    aka: _0(), emerg()

 alert

    Level 1

    aka: _1()

 critical

    Level 2

    aka: _2(), crit()

 error

    Level 3

    aka: _3(), err()

 warning

    Level 4

    aka: _4(), warn()

 notice

    Level 5

    aka: _5()

 info

    Level 6

    aka: _6()

 debug

    Level 7

    aka: _7()

HELPER METHODS

    These methods may be handy to the end user, but aren't required for
    end-use.

 levels('names')

    Returns the hash of level_num => level_name mapping.

    If the optional string names is sent in, we'll return an array of just
    the names, in numeric order from lowest to highest.

 timestamp

    Returns the current time in the following format: 2016-03-17
    17:51:02.241 

AUTHOR

    Steve Bertrand, <steveb at cpan.org>

BUGS

    Please report any bugs or feature requests to
    https://github.com/stevieb9/p5-log-simple/issues

REPOSITORY

    https://github.com/stevieb9/p5-log-simple

BUILD RESULTS (THIS VERSION)

    CPAN Testers: http://matrix.cpantesters.org/?dist=Log-Simple

SUPPORT

    You can find documentation for this module with the perldoc command.

        perldoc Log::Simple

SEE ALSO

    There are too many other logging modules to list here, but the idea for
    this one came from Log::Basic. However, this one was written completely
    from scratch.

LICENSE AND COPYRIGHT

    Copyright 2016 Steve Bertrand.

    This program is free software; you can redistribute it and/or modify it
    under the terms of either: the GNU General Public License as published
    by the Free Software Foundation; or the Artistic License.

    See http://dev.perl.org/licenses/ for more information.