logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Log::Any::Adapter::FileHandle - A basic Log::Any::Adapter to forward messages to a filehandle

Description

       This module is a basic adapter that will simply forward log messages to a filehandle, or any object that
       supports a 'print' method (IO::String, IO::Socket::INET, Plack's $env->{psgi.errors} object, etc).

       I've created it so that my scripts running under damontools or runit can output messages to locally
       defined logs.  It does not timestamp messages, that responsbility  is delegated to the external log
       capture mechanism.

       You can override the default configuration by passing extra arguments to the "Log::Any" set_adapter
       method:

       fh  Pass  in  your  IO::Handle-like  object  here.   If  this isn't specified, it will default to opening
           STDERR.  If the object supports an autoflush method, autoflush will be enabled,  unless  no_autoflush
           is set.

       no_autoflush
           Disable automatically turning on autoflush on the fh object.

       format
           A  sprintf  string  that controls the formatting of the message.  It is supplied 2 arguments: the log
           level as supplied by Log::Any (usually all-lowercase), and the message to be logged.  The default  is
           "[%s] %s\n".  This value should contain the log record terminator, such as a newline.

       escape
           one  of  'none'  (default),  'newline', or 'nonascii'.  Controls how messages are pre-filtered before
           passing them to a filehandle. This is handy if you want do smoosh messages into a  single  line  (for
           easier  filtering  +  processing),  or  if  you want to filter non ascii characters for safe terminal
           printing.

Name

       Log::Any::Adapter::FileHandle - A basic Log::Any::Adapter to forward messages to a filehandle

Synopsis

         use Log::Any qw($log);
         use Log::Any::Adapter;

         # Send all logs to Log::Any::Adapter::FileHandle
         Log::Any::Adapter->set('FileHandle');

         $log->info("Hello world");

Version

       version 0.010

See Also