[system] / trunk / webwork2 / lib / Apache / WeBWorK.pm Repository:
ViewVC logotype

Diff of /trunk/webwork2/lib/Apache/WeBWorK.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 4195 Revision 4196
35use WeBWorK; 35use WeBWorK;
36 36
37use mod_perl; 37use mod_perl;
38use constant MP2 => ( exists $ENV{MOD_PERL_API_VERSION} and $ENV{MOD_PERL_API_VERSION} >= 2 ); 38use constant MP2 => ( exists $ENV{MOD_PERL_API_VERSION} and $ENV{MOD_PERL_API_VERSION} >= 2 );
39 39
40# load correct 40# load correct logging module
41BEGIN { 41BEGIN {
42 if (MP2) { 42 if (MP2) {
43 # FIXME need to load Apache2::Log 43 require Apache2::Log;
44 Apache2::Log->import;
44 } else { 45 } else {
45 require Apache::Log; 46 require Apache::Log;
46 Apache::Log->import; 47 Apache::Log->import;
47 } 48 }
48} 49}
62 my $log = $r->log; 63 my $log = $r->log;
63 my $uri = $r->uri; 64 my $uri = $r->uri;
64 65
65 # the warning handler accumulates warnings in $r->notes("warnings") for 66 # the warning handler accumulates warnings in $r->notes("warnings") for
66 # later cumulative reporting 67 # later cumulative reporting
68 my $warning_handler;
69 if (MP2) {
67 my $warning_handler = sub { 70 $warning_handler = sub {
68 my ($warning) = @_; 71 my ($warning) = @_;
69 chomp $warning; 72 chomp $warning;
73
74 my $warnings = $r->notes->get("warnings");
75 $warnings .= "$warning\n";
76 #my $backtrace = join("\n",backtrace());
77 #$warnings .= "$backtrace\n\n";
78 $r->notes->set(warnings => $warnings);
79
80 $log->warn("[$uri] $warning");
81 };
82 } else {
83 $warning_handler = sub {
84 my ($warning) = @_;
85 chomp $warning;
86
87 my $warnings = $r->notes("warnings");
88 $warnings .= "$warning\n";
89 #my $backtrace = join("\n",backtrace());
90 #$warnings .= "$backtrace\n\n";
91 $r->notes("warnings" => $warnings);
92
93 $log->warn("[$uri] $warning");
94 };
70 95
71 my $warnings = MP2 ? $r->notes->get("warnings") : $r->notes("warnings"); 96 # the exception handler generates a backtrace when catching an exception
72 $warnings .= "$warning\n"; 97 my @backtrace;
73 MP2 ? $r->notes->set(warnings => $warnings) : $r->notes("warnings" => $warnings); 98 my $exception_handler = sub {
74 99 @backtrace = backtrace();
75 $log->warn("[$uri] $warning"); 100 die @_;
76 }; 101 };
102 }
77 103
78 # the exception handler generates a backtrace when catching an exception 104 # the exception handler generates a backtrace when catching an exception
79 my @backtrace; 105 my @backtrace;
80 my $exception_handler = sub { 106 my $exception_handler = sub {
81 @backtrace = backtrace(); 107 @backtrace = backtrace();

Legend:
Removed from v.4195  
changed lines
  Added in v.4196

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9