From eb69ed59aff885c9b7b129c159484f539f4b0841 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 27 Jan 2010 09:08:48 +0100 Subject: [PATCH] Weiteres Debug-Level und Funktionen zur Anzeige, wie lange ein Request gedauert hat --- SL/LXDebug.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/SL/LXDebug.pm b/SL/LXDebug.pm index f9dfa9836..47702bf6d 100644 --- a/SL/LXDebug.pm +++ b/SL/LXDebug.pm @@ -7,14 +7,15 @@ use constant DEBUG2 => 1 << 2; 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; @@ -227,4 +228,16 @@ sub level2string { 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; -- 2.20.1