[Rt-commit] rt branch, 4.4/cli-statement-log, created. rt-4.4.4-105-g4f2083525c

? sunnavy sunnavy at bestpractical.com
Mon Sep 14 18:01:29 EDT 2020


The branch, 4.4/cli-statement-log has been created
        at  4f2083525c218fc8462674203b70ba5f1a4b5495 (commit)

- Log -----------------------------------------------------------------
commit 4f2083525c218fc8462674203b70ba5f1a4b5495
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed May 20 03:38:39 2020 +0800

    Add statement-log option to render statement logs in CLI

diff --git a/lib/RT/Interface/CLI.pm b/lib/RT/Interface/CLI.pm
index 2119bca773..6341d65ec3 100644
--- a/lib/RT/Interface/CLI.pm
+++ b/lib/RT/Interface/CLI.pm
@@ -195,6 +195,9 @@ sub Init {
     push @args, "quiet|q!" => \($hash->{quiet})
         unless $exists{quiet};
 
+    push @args, "statement-log=s" => \($hash->{'statement-log'})
+        unless $exists{'statement-log'};
+
     my $ok = Getopt::Long::GetOptions( @args );
     Pod::Usage::pod2usage(1) if not $ok and not defined wantarray;
 
@@ -214,7 +217,9 @@ sub Init {
         RT->Config->Set(LogToSTDERR => "warning");
     }
 
+    RT->Config->Set( 'StatementLog', $hash->{'statement-log'} ) if defined $hash->{'statement-log'};
     RT::Init();
+    $RT::Handle->LogSQLStatements(1) if RT->Config->Get('StatementLog');
 
     $| = 1;
 
@@ -223,4 +228,12 @@ sub Init {
 
 RT::Base->_ImportOverlays();
 
+END {
+
+    # When pod2usage is called(e.g. with --help), RT.pm won't be
+    # required and directly calling RT->Config will error out.
+    RT::Interface::Web::LogRecordedSQLStatements( RequestData => { Path => '/' } )
+        if RT->can('Config') && RT->Config->Get('StatementLog');
+}
+
 1;

-----------------------------------------------------------------------


More information about the rt-commit mailing list