[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [234] trunk
- Subject: SF.net SVN: ledger-smb: [234] trunk
- From: ..hidden..
- Date: Wed, 18 Oct 2006 21:50:42 -0700
Revision: 234
http://svn.sourceforge.net/ledger-smb/?rev=234&view=rev
Author: einhverfr
Date: 2006-10-18 21:50:36 -0700 (Wed, 18 Oct 2006)
Log Message:
-----------
Added Jason's logging module
Modified Paths:
--------------
trunk/Changelog
trunk/LedgerSMB/Sysconfig.pm
Added Paths:
-----------
trunk/LedgerSMB/Log.pm
Modified: trunk/Changelog
===================================================================
--- trunk/Changelog 2006-10-19 04:29:09 UTC (rev 233)
+++ trunk/Changelog 2006-10-19 04:50:36 UTC (rev 234)
@@ -1,5 +1,6 @@
Changelog for LedgerSMB 1.2.0
+* Added logging module (Jason R)
* Corrected parsing of numbers so that they are multi-run safe (Chris T)
* Added first version of rpm spec from Mads Kiilerich (Chris T)
* Added "1 000.00" number format (Chris T)
Added: trunk/LedgerSMB/Log.pm
===================================================================
--- trunk/LedgerSMB/Log.pm (rev 0)
+++ trunk/LedgerSMB/Log.pm 2006-10-19 04:50:36 UTC (rev 234)
@@ -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;
Modified: trunk/LedgerSMB/Sysconfig.pm
===================================================================
--- trunk/LedgerSMB/Sysconfig.pm 2006-10-19 04:29:09 UTC (rev 233)
+++ trunk/LedgerSMB/Sysconfig.pm 2006-10-19 04:50:36 UTC (rev 234)
@@ -5,3 +5,9 @@
package LSMBConfig;
$session='DB';
+$logging=0; # No logging on by default
+
+
+
+
+1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.