[Jifty-commit] r4631 - in jifty/trunk: lib/Jifty/Plugin
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Dec 6 16:17:44 EST 2007
Author: sartak
Date: Thu Dec 6 16:17:42 2007
New Revision: 4631
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Plugin/Recorder.pm
Log:
r48725 at onn: sartak | 2007-12-06 16:15:51 -0500
Recorder: Defer loghandle creation until first hit, so not all commands are creating request logs
Modified: jifty/trunk/lib/Jifty/Plugin/Recorder.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Recorder.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/Recorder.pm Thu Dec 6 16:17:42 2007
@@ -30,14 +30,9 @@
$self->path(Jifty::Util->absolute_path( $args{path} ));
Jifty::Util->make_path($self->path);
- $self->loghandle($self->get_loghandle);
-
- # if creating the loghandle failed, then we may as well not bother :)
- if ($self->loghandle) {
- Jifty::Handler->add_trigger(
- before_request => sub { $self->before_request(@_) }
- );
- }
+ Jifty::Handler->add_trigger(
+ before_request => sub { $self->before_request(@_) }
+ );
}
=head2 before_request
@@ -57,7 +52,7 @@
my $request = { cgi => nfreeze($cgi), ENV => \%ENV, time => $delta };
my $yaml = Jifty::YAML::Dump($request);
- print { $self->loghandle } $yaml;
+ print { $self->get_loghandle } $yaml;
};
Jifty->log->error("Unable to append to request log: $@") if $@;
@@ -74,19 +69,22 @@
sub get_loghandle {
my $self = shift;
- my $name = sprintf '%s/%d-%d.log',
- $self->path,
- $self->start,
- $$;
-
- open my $loghandle, '>', $name or do {
- Jifty->log->error("Unable to open $name for writing: $!");
- return;
- };
+ unless ($self->loghandle) {
+ my $name = sprintf '%s/%d-%d.log',
+ $self->path,
+ $self->start,
+ $$;
+
+ open my $loghandle, '>', $name or do {
+ Jifty->log->error("Unable to open $name for writing: $!");
+ return;
+ };
- Jifty->log->info("Logging all HTTP requests to $name.");
+ Jifty->log->info("Logging all HTTP requests to $name.");
+ $self->loghandle($loghandle);
+ }
- return $loghandle;
+ return $self->loghandle;
}
=head1 NAME
More information about the Jifty-commit
mailing list