From 77ddeab9e3b62bf43dc57324b4ac19ac6ee91859 Mon Sep 17 00:00:00 2001 From: Jason Crome Date: Thu, 22 Feb 2024 11:51:47 -0500 Subject: [PATCH] Rewrite dashboard emailer to use the CLI interface This allows for the generation of statement logs from the command line when sending dashboards via email. --- sbin/rt-email-dashboards.in | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/sbin/rt-email-dashboards.in b/sbin/rt-email-dashboards.in index 4b3b0087823..80b7db926db 100644 --- a/sbin/rt-email-dashboards.in +++ b/sbin/rt-email-dashboards.in @@ -66,38 +66,18 @@ BEGIN { # BEGIN RT CMD BOILERPLATE } -# Read in the options +use RT::Interface::CLI qw(Init); my %opts; -use Getopt::Long; -GetOptions( \%opts, - "help|h", "dryrun", "time=i", "epoch=i", "all", "log=s", "user=s", "recipient=s@", "dashboards=s" +Init( \%opts, + "dryrun", "time=i", "epoch=i", "all", "user=s", "recipient=s@", "dashboards=s" ); -if ($opts{'help'}) { - require Pod::Usage; - print Pod::Usage::pod2usage(-verbose => 2); - exit; -} - -require RT; -require RT::Interface::CLI; -RT::Interface::CLI->import(qw{ loc }); - -# Load the config file -RT::LoadConfig(); - -# adjust logging to the screen according to options -RT->Config->Set( LogToSTDERR => $opts{log} ) if $opts{log}; - # Disable JS chart as email clients don't support it RT->Config->Set( EnableJSChart => 0 ); # Disable inline editing as email clients don't support it RT->Config->Set( InlineEdit => 0 ); -# Connect to the database and get RT::SystemUser and RT::Nobody loaded -RT::Init(); - require RT::Dashboard::Mailer; RT::Dashboard::Mailer->MailDashboards( All => $opts{all}, @@ -191,6 +171,11 @@ the subscription settings in the web UI. Adjust LogToSTDERR config option +=item --statement-log LEVEL + +Log any SQL queries produced at the specified log level. This works +similar to the C<$StatementLog> option in the main RT config file. + =back =cut