summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Error.pm
diff options
context:
space:
mode:
authorbugreport%peshkin.net <>2004-07-21 06:34:41 +0200
committerbugreport%peshkin.net <>2004-07-21 06:34:41 +0200
commit9bbbeca380788e11cbc57b310988b16d6b77586a (patch)
treed6b61d25f2aa60e6116890b3454555cc4c74803c /Bugzilla/Error.pm
parent018ed17c864b55b8a3bf5cca601f84fab2e77938 (diff)
downloadbugzilla-9bbbeca380788e11cbc57b310988b16d6b77586a.tar.gz
bugzilla-9bbbeca380788e11cbc57b310988b16d6b77586a.tar.xz
Bug 165589 Add data/errorlog logging support to bugzilla
r=jouni a=myk
Diffstat (limited to 'Bugzilla/Error.pm')
-rw-r--r--Bugzilla/Error.pm31
1 files changed, 31 insertions, 0 deletions
diff --git a/Bugzilla/Error.pm b/Bugzilla/Error.pm
index e511a575c..be7f87add 100644
--- a/Bugzilla/Error.pm
+++ b/Bugzilla/Error.pm
@@ -28,6 +28,7 @@ use base qw(Exporter);
use Bugzilla::Config;
use Bugzilla::Util;
+use Date::Format;
sub _throw_error {
my ($name, $error, $vars, $unlock_tables) = @_;
@@ -38,6 +39,36 @@ sub _throw_error {
Bugzilla->dbh->do("UNLOCK TABLES") if $unlock_tables;
+ # If a writable data/errorlog exists, log error details there.
+ if (-w "data/errorlog") {
+ require Data::Dumper;
+ my $mesg = "";
+ for (1..75) { $mesg .= "-"; };
+ $mesg .= "\n[$$] " . time2str("%D %H:%M:%S ", time());
+ $mesg .= "$name $error ";
+ $mesg .= "$ENV{REMOTE_ADDR} " if $ENV{REMOTE_ADDR};
+ $mesg .= Bugzilla->user->login if Bugzilla->user;
+ $mesg .= "\n";
+ my %params = Bugzilla->cgi->Vars;
+ $Data::Dumper::Useqq = 1;
+ for my $param (sort keys %params) {
+ my $val = $params{$param};
+ # obscure passwords
+ $val = "*****" if $param =~ /password/i;
+ # limit line length
+ $val =~ s/^(.{512}).*$/$1\[CHOP\]/;
+ $mesg .= "[$$] " . Data::Dumper->Dump([$val],["param($param)"]);
+ }
+ for my $var (sort keys %ENV) {
+ my $val = $ENV{$var};
+ $val = "*****" if $val =~ /password|http_pass/i;
+ $mesg .= "[$$] " . Data::Dumper->Dump([$val],["env($var)"]);
+ }
+ open(ERRORLOGFID, ">>data/errorlog");
+ print ERRORLOGFID "$mesg\n";
+ close ERRORLOGFID;
+ }
+
print Bugzilla->cgi->header();
my $template = Bugzilla->template;