summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlinuxpoet <linuxpoet@4979c152-3d1c-0410-bac9-87ea11338e46>2007-03-17 01:50:10 +0000
committerlinuxpoet <linuxpoet@4979c152-3d1c-0410-bac9-87ea11338e46>2007-03-17 01:50:10 +0000
commit7ea0aab4590f2e64f0cad4ab4446b6cc470a9173 (patch)
treed6701c860980cdc1a18495f95e316061b8cbbeef
parent50652463a99eac34dc89d85569d6d0d3e74e8316 (diff)
backport changes for log to just print to STDERR from 1.3 to 1.2
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@922 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--LedgerSMB/Log.pm34
1 files changed, 18 insertions, 16 deletions
diff --git a/LedgerSMB/Log.pm b/LedgerSMB/Log.pm
index f816660b..0613132b 100644
--- a/LedgerSMB/Log.pm
+++ b/LedgerSMB/Log.pm
@@ -13,6 +13,7 @@ This module is loosly based on Apache::Log.
Available methods: (in order, most to least severe)
+
=over 4
=item emerg
@@ -31,6 +32,14 @@ Available methods: (in order, most to least severe)
=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 warnings;
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.
-
- $fh=IO::File->new('>>users/ledger-smb.log');
- $fh->autoflush(1);
- __PACKAGE__->print('general',"Log file opened");
- }
+ $log_line = sprintf('[%s] [%s] %i %s', scalar(localtime), +shift, $$, join(' ',@_))."\n";
+ print STDERR $log_line;
- $fh->print(sprintf('[%s] [%s] %i %s',
- scalar(localtime),
- +shift,
- $$,
- join(' ',@_))."\n");
}
@@ -76,11 +75,14 @@ sub warn { shift->print('warn',@_) }
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([@_]);
$d->Sortkeys(1);
- $self->print('dump',$d->Dump());
+ $self->print('debug',$d->Dump());
}
1;