[Rt-commit] rt branch 5.0/rest2-statement-log created. rt-5.0.5-151-gc1447d91fd
BPS Git Server
git at git.bestpractical.com
Tue Jan 30 18:52:21 UTC 2024
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/rest2-statement-log has been created
at c1447d91fdb4f3f6140f9d0f28be2bd2c0c40c73 (commit)
- Log -----------------------------------------------------------------
commit c1447d91fdb4f3f6140f9d0f28be2bd2c0c40c73
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Jan 30 13:47:59 2024 -0500
Add StatementLog support for REST2
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index e47fa96069..c9322259a2 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1426,8 +1426,10 @@ sub LogRecordedSQLStatements {
$RT::Handle->AddRequestToHistory({
%{ $args{RequestData} },
Queries => \@log,
- });
+ }) if $args{RequestData};
+ my $current_user = $args{CurrentUser} || $HTML::Mason::Commands::session{'CurrentUser'};
+ my $current_user_name = $current_user ? $current_user->Name : '';
for my $stmt (@log) {
my ( $time, $sql, $bind, $duration ) = @{$stmt};
my @bind;
@@ -1440,7 +1442,7 @@ sub LogRecordedSQLStatements {
}
$RT::Logger->log(
level => $log_sql_statements,
- message => ($HTML::Mason::Commands::session{'CurrentUser'} ? $HTML::Mason::Commands::session{'CurrentUser'}->Name : '')
+ message => $current_user_name
. " - "
. "SQL("
. sprintf( "%.6f", $duration )
diff --git a/lib/RT/REST2/Dispatcher.pm b/lib/RT/REST2/Dispatcher.pm
index 74ca7d1060..87394b470f 100644
--- a/lib/RT/REST2/Dispatcher.pm
+++ b/lib/RT/REST2/Dispatcher.pm
@@ -94,6 +94,8 @@ sub to_psgi_app {
RT->SetCurrentInterface('REST2');
RT::ConnectToDatabase();
+ RT::Interface::Web::MaybeEnableSQLStatementLog();
+
my $dispatch = $self->_dispatcher->dispatch($env->{PATH_INFO});
return [404, ['Content-Type' => 'text/plain'], 'Not Found']
diff --git a/lib/RT/REST2/Middleware/Log.pm b/lib/RT/REST2/Middleware/Log.pm
index 88a45a2ea0..1c77065e06 100644
--- a/lib/RT/REST2/Middleware/Log.pm
+++ b/lib/RT/REST2/Middleware/Log.pm
@@ -62,7 +62,9 @@ sub call {
RT->Logger->log(%$what);
};
- return $self->app->($env);
+ my $ret = $self->app->($env);
+ RT::Interface::Web::LogRecordedSQLStatements( CurrentUser => $env->{'rt.current_user'} );
+ return $ret;
}
1;
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list