use constant QUERY => 1 << 3;
use constant TRACE => 1 << 4;
use constant BACKTRACE_ON_ERROR => 1 << 5;
-use constant ALL => (1 << 6) - 1;
-use constant DEVEL => INFO | QUERY | TRACE | BACKTRACE_ON_ERROR;
+use constant REQUEST_TIMER => 1 << 6;
+use constant ALL => (1 << 7) - 1;
+use constant DEVEL => INFO | QUERY | TRACE | BACKTRACE_ON_ERROR | REQUEST_TIMER;
use constant FILE_TARGET => 0;
use constant STDERR_TARGET => 1;
use POSIX qw(strftime);
-
+use Time::HiRes qw(gettimeofday tv_interval);
use YAML;
use strict;
join '/', qw(info debug1 debug2 query trace error_call_trace)[ grep { (reverse split //, sprintf "%05b", $_[0])[$_] } 0..5 ]
}
+sub begin_request {
+ my $self = shift;
+ return 1 unless ($global_level & REQUEST_TIMER);
+ $self->{request_start} = [gettimeofday];
+}
+
+sub end_request {
+ my $self = shift;
+ return 1 unless ($global_level & REQUEST_TIMER);
+ $self->_write("time", tv_interval($self->{request_start}));
+}
+
1;