diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-10-19 04:50:36 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-10-19 04:50:36 +0000 |
commit | 988e6ffa611097514cffcbd7b8b0a7a6d0f6d058 (patch) | |
tree | a18c28b97650b34d73b16a405cb91eb673c44e4d /LedgerSMB | |
parent | 81077804ebe47b51b1959055889658e7ca6fc102 (diff) |
Added Jason's logging module
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@234 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB')
-rw-r--r-- | LedgerSMB/Log.pm | 81 | ||||
-rw-r--r-- | LedgerSMB/Sysconfig.pm | 6 |
2 files changed, 87 insertions, 0 deletions
diff --git a/LedgerSMB/Log.pm b/LedgerSMB/Log.pm new file mode 100644 index 00000000..954a1a6b --- /dev/null +++ b/LedgerSMB/Log.pm @@ -0,0 +1,81 @@ +=head1 NAME + +LedgerSMB::Log - LedgerSMB logging and debugging framework + +=head1 SYOPSIS + +This module maintains a connection to the LedgerSMB log file +(Seperate from the apche error log, for now) + +=head1 METHODS + +This module is loosly based on Apache::Log. + +Available methods: (in order, most to least severe) + +=over 4 + +=item emerg + +=item alert + +=item crit + +=item error + +=item warn + +=item notice + +=item info + +=item debug + +=back + +=cut + +package LedgerSMB::Log; +use strict; +use warnings; +use IO::File; +use Data::Dumper; +use LedgerSMB::Sysconfig; + + +our $fh; + +sub print { + if (!$LSMBConfig::logging){ + return 0; + } + shift; + unless($fh) { + # TODO: this is grosly wrong, but so is this module in the first place. + # the log messages *should* end up in the apache log, but that will + # hopefully be corrected in the future. + + $fh=IO::File->new('>>users/ledger-smb.log'); + $fh->autoflush(1); + __PACKAGE__->print('general',"Log file opened"); + } + + $fh->print(sprintf('[%s] [%s] %i %s', + scalar(localtime), + +shift, + $$, + join(' ',@_))."\n"); +} + + +sub emerg { shift->print('emerg',@_) } +sub alert { shift->print('alert',@_) } +sub crit { shift->print('crit',@_) } +sub error { shift->print('error',@_) } +sub warn { shift->print('warn',@_) } +sub notice { shift->print('notice',@_) } +sub info { shift->print('info',@_) } +sub debug { shift->print('debug',@_) } +sub dump { shift->print('dump',Dumper(@_)) } + +1; diff --git a/LedgerSMB/Sysconfig.pm b/LedgerSMB/Sysconfig.pm index fdc27715..983675ff 100644 --- a/LedgerSMB/Sysconfig.pm +++ b/LedgerSMB/Sysconfig.pm @@ -5,3 +5,9 @@ package LSMBConfig; $session='DB'; +$logging=0; # No logging on by default + + + + +1; |