[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [922] branches/1.2/LedgerSMB/Log.pm
- Subject: SF.net SVN: ledger-smb: [922] branches/1.2/LedgerSMB/Log.pm
- From: ..hidden..
- Date: Fri, 16 Mar 2007 18:50:11 -0700
Revision: 922
http://svn.sourceforge.net/ledger-smb/?rev=922&view=rev
Author: linuxpoet
Date: 2007-03-16 18:50:10 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
backport changes for log to just print to STDERR from 1.3 to 1.2
Modified Paths:
--------------
branches/1.2/LedgerSMB/Log.pm
Modified: branches/1.2/LedgerSMB/Log.pm
===================================================================
--- branches/1.2/LedgerSMB/Log.pm 2007-03-17 00:08:42 UTC (rev 921)
+++ branches/1.2/LedgerSMB/Log.pm 2007-03-17 01:50:10 UTC (rev 922)
@@ -13,6 +13,7 @@
Available methods: (in order, most to least severe)
+
=over 4
=item emerg
@@ -31,6 +32,14 @@
=item debug
+=item longmess
+
+This uses Carp to make a debug message with the full stack backtrace, including function arguments, where Carp can infer them.
+
+=item dump
+
+This uses Data::Dumper to dump the contents of a data structure as a debug message.
+
=back
=cut
@@ -41,30 +50,20 @@
use IO::File;
use Data::Dumper;
use LedgerSMB::Sysconfig;
+use Carp ();
+our $VERSION = '1.0.0';
-our $fh;
+our $log_line;
sub print {
if (!$LedgerSMB::Sysconfig::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.
+ $log_line = sprintf('[%s] [%s] %i %s', scalar(localtime), +shift, $$, join(' ',@_))."\n";
+ print STDERR $log_line;
- $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");
}
@@ -76,11 +75,14 @@
sub notice { shift->print('notice',@_) }
sub info { shift->print('info',@_) }
sub debug { shift->print('debug',@_) }
+
+sub longmess { shift->print('debug',Carp::longmess(@_)) }
+
sub dump {
my $self = shift;
my $d = Data::Dumper->new(..hidden..);
$d->Sortkeys(1);
- $self->print('dump',$d->Dump());
+ $self->print('debug',$d->Dump());
}
1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.