[Rt-commit] r3873 - in rt/branches/QUEBEC-EXPERIMENTAL: . etc html
lib
alexmv at bestpractical.com
alexmv at bestpractical.com
Thu Sep 22 12:38:35 EDT 2005
Author: alexmv
Date: Thu Sep 22 12:38:34 2005
New Revision: 3873
Modified:
rt/branches/QUEBEC-EXPERIMENTAL/ (props changed)
rt/branches/QUEBEC-EXPERIMENTAL/etc/RT_Config.pm.in
rt/branches/QUEBEC-EXPERIMENTAL/html/autohandler
rt/branches/QUEBEC-EXPERIMENTAL/lib/RT.pm.in
Log:
r6451 at zoq-fot-pik: chmrr | 2005-09-22 12:37:30 -0400
* Statement logging
Modified: rt/branches/QUEBEC-EXPERIMENTAL/etc/RT_Config.pm.in
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/etc/RT_Config.pm.in (original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/etc/RT_Config.pm.in Thu Sep 22 12:38:34 2005
@@ -282,6 +282,11 @@
@LogToSyslogConf = () unless (@LogToSyslogConf);
+# RT has rudimentary SQL statement logging support if you have
+# DBIx-SearchBuilder 1.31_1 or higher; simply set $StatementLog to be
+# the level that you wish SQL statements to be logged at.
+Set($StatementLog, undef);
+
# }}}
# {{{ Web interface configuration
Modified: rt/branches/QUEBEC-EXPERIMENTAL/html/autohandler
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/html/autohandler (original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/html/autohandler Thu Sep 22 12:38:34 2005
@@ -49,6 +49,11 @@
$RT::Handle->ForceRollback() if $RT::Handle->TransactionDepth;
+if ($RT::StatementLog) {
+ $RT::Handle->ClearSQLStatementLog;
+ $RT::Handle->LogSQLStatements(1);
+}
+
local *session unless $m->is_subrequest; # avoid reentrancy, as suggested by masonbook
# Disable AutoFlush using an attribute
@@ -239,6 +244,25 @@
$m->comp('/Elements/Login', %ARGS);
$m->abort();
}
+
+if ($RT::StatementLog) {
+ my @log = $RT::Handle->SQLStatementLog;
+ $RT::Handle->ClearSQLStatementLog;
+ for my $stmt (@log) {
+ my ($time, $sql, $bind, $duration) = @{$stmt};
+ my @bind;
+ if (ref $bind) {
+ @bind = @{$bind};
+ } else {
+ # Older DBIx-SB
+ $duration = $bind;
+ }
+ $RT::Logger->log( level => $RT::StatementLog,
+ message => "SQL(".sprintf("%.2f",$duration)."s): $sql;" . (@bind ? " [ bound values: @{[map{qq|'$_'|} @bind]} ]" : "")
+ );
+ }
+}
+
</%INIT>
<& /Elements/Footer, %ARGS &>
<%ARGS>
Modified: rt/branches/QUEBEC-EXPERIMENTAL/lib/RT.pm.in
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/lib/RT.pm.in (original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/lib/RT.pm.in Thu Sep 22 12:38:34 2005
@@ -161,7 +161,7 @@
InitLogging();
}
-
+
=head2 ConnectToDatabase
Get a database connection
@@ -175,7 +175,7 @@
}
$Handle->Connect();
}
-
+
=head2 InitLogging
Create the RT::Logger object.
More information about the Rt-commit
mailing list