App-Regather
view release on metacpan or search on metacpan
lib/App/Regather/Logg.pm view on Meta::CPAN
# -*- mode: cperl; eval: (follow-mode) -*-
#
package App::Regather::Logg;
use strict;
use warnings;
use diagnostics;
use Sys::Syslog qw(:standard :macros);
use Mail::Send;
use POSIX qw(strftime);
use Sys::Hostname;
use Data::Printer caller_info => 1, class => { expand => 2 };
# https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg
use constant DPC => { info => 'green',
err => 'red',
debug => 'magenta',
warning => 'yellow', };
=pod
=encoding UTF-8
=head1 NAME
App::Regather::Logg - logging class
=head1 SYNOPSIS
use App::Regather::Logg;
my $log = new App::Regather::Logg( prognam => 'MyAppName',
foreground => $foreground_or_syslog,
colors => $wheather_to_use_term_colors );
$log->cc( pr => 'info', fm => "App::Regather::Logg initialized ... (write to syslog)" );
$log->cc( fg => 1, fm => "App::Regather::Logg initialized ... (write to STDOUT)" );
...
my $mesg = $ldap->search( filter => "(objectClass=unsearchebleThing)");
$log->logg_ldap_err( mesg => $mesg );
=head1 DESCRIPTION
This is a class to log messages.
=head1 CONSTRUCTOR
=over 4
=item B<new>
Creates a new B<App::Regather::Logg> object
=over 4
=item prognam =E<gt> 'MyAppName'
program name
=item foreground =E<gt> 1 | 0
STDOUT or syslog, default is: 0
=item colors =E<gt> 1 | 0
wheather to use terminal colors, default is: 0
if set, then priorities are colored this way:
=over 4
info => 'ansi113'
err => 'bold ansi255 on_ansi196'
debug => 'ansi195'
( run in 1.157 second using v1.01-cache-2.11-cpan-b16cb0d3907 )