From 72427d00a839573de7c1ac1e6e25ad43d6d33716 Mon Sep 17 00:00:00 2001 From: "Kevin L. Esteb" Date: Fri, 13 Jan 2017 15:22:53 -0800 Subject: [PATCH] made changes to Badger::Log/Badger::Log::File for better configuration --- lib/Badger/Log.pm | 152 +++++++++++++++++++++++++++++------------ lib/Badger/Log/File.pm | 2 +- 2 files changed, 108 insertions(+), 46 deletions(-) diff --git a/lib/Badger/Log.pm b/lib/Badger/Log.pm index fdb923b..4ce8528 100644 --- a/lib/Badger/Log.pm +++ b/lib/Badger/Log.pm @@ -7,38 +7,55 @@ # # AUTHOR # Andy Wardley +# Kevin L. Esteb (13-Jan-2017) +# use Badger::Timestamp for the timestamp +# added configuration variable 'strftime' for changing the timestamp format +# decoupled toggling levels from actual level output +# added CALLBACKS package variable to control output +# callbacks are passed $self, $level, $message +# added callback() method to manipulate CALLBACKS variable # #======================================================================== package Badger::Log; +use Badger::Timestamp; use Badger::Class - version => 0.01, - base => 'Badger::Prototype', - import => 'class', - utils => 'blessed', - config => 'system|class:SYSTEM format|class:FORMAT', - constants => 'ARRAY CODE', - constant => { - MSG => '_msg', # suffix for message methods, e.g. warn_msg() - LOG => 'log', # method a delegate must implement + version => 0.02, + base => 'Badger::Prototype', + utils => 'blessed', + config => 'system|class:SYSTEM format|class:FORMAT strftime|class:STRFTIME', + import => 'class', + constants => 'ARRAY CODE', + constant => { + MSG => '_msg', + LOG => 'log', + }, + vars => { + CALLBACKS => { + debug => \&_output, + trace => \&_output, + info => \&_output, + warn => \&_output, + error => \&_output, + fatal => \&_output, }, - vars => { - SYSTEM => 'Badger', - FORMAT => '[