[Rt-commit] rt branch 4.4/cli-support-log created. rt-4.4.5-14-gf74341a38a
BPS Git Server
git at git.bestpractical.com
Tue Jan 4 21:26:48 UTC 2022
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, 4.4/cli-support-log has been created
at f74341a38a0038bf2cddb8eec0ed3f0df0f7c150 (commit)
- Log -----------------------------------------------------------------
commit f74341a38a0038bf2cddb8eec0ed3f0df0f7c150
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Jan 5 04:40:43 2022 +0800
Add --log support in RT::Interface::CLI
rt-crontool supported --log explicitly but set LogToSTDERR too
late(after Init) to catch init logs. By adding --log in
RT::Interface::CLI, we can set log level from the beginning.
diff --git a/bin/rt-crontool.in b/bin/rt-crontool.in
index db2d04afd7..4da81f5030 100644
--- a/bin/rt-crontool.in
+++ b/bin/rt-crontool.in
@@ -74,7 +74,7 @@ use Getopt::Long;
use RT::Interface::CLI qw(GetCurrentUser Init loc);
my ( $search, $condition, $actions, $search_arg, $condition_arg, $actions_arg,
- $template, $template_id, $transaction, $transaction_type, $reload_ticket, $log, $verbose,
+ $template, $template_id, $transaction, $transaction_type, $reload_ticket, $verbose,
$max_processes, $max_tickets_per_process, $dryrun );
my %OPT = (
@@ -91,16 +91,12 @@ my %OPT = (
"reload-ticket" => \$reload_ticket,
"max-processes=i" => \$max_processes,
"max-tickets-per-process=i" => \$max_tickets_per_process,
- "log=s" => \$log,
"verbose|v" => \$verbose,
"dry-run" => \$dryrun,
);
Init( %OPT );
-# adjust logging to the screen according to options
-RT->Config->Set( LogToSTDERR => $log ) if $log;
-
require RT::Tickets;
require RT::Template;
@@ -168,7 +164,7 @@ if ($max_processes) {
# Reconnect to DB and initialize logging in each child
$RT::Handle->Connect;
- RT->Config->Set( 'LogToFile', $log || RT->Config->Get('LogToSTDERR') );
+ RT->Config->Set( 'LogToFile', RT->Config->Get('LogToSTDERR') );
RT->Config->Set( 'LogToFileNamed', 'rt-crontool-' . time . "-$$.log" );
undef $RT::Logger;
RT::InitLogging();
diff --git a/lib/RT/Interface/CLI.pm b/lib/RT/Interface/CLI.pm
index 821e71b31b..6ef0093e38 100644
--- a/lib/RT/Interface/CLI.pm
+++ b/lib/RT/Interface/CLI.pm
@@ -213,6 +213,8 @@ sub Init {
push @args, "quiet|q!" => \($hash->{quiet})
unless $exists{quiet};
+ push @args, "log=s" => \($hash->{log}) unless $exists{log};
+
push @args, "statement-log=s" => \($hash->{'statement-log'})
unless $exists{'statement-log'};
@@ -227,7 +229,9 @@ sub Init {
require RT;
RT::LoadConfig();
- if (not $exists{quiet} and $hash->{quiet}) {
+ if ( $hash->{log} ) {
+ RT->Config->Set(LogToSTDERR => $hash->{log});
+ } elsif (not $exists{quiet} and $hash->{quiet}) {
RT->Config->Set(LogToSTDERR => "error");
} elsif (not $exists{verbose} and $hash->{verbose}) {
RT->Config->Set(LogToSTDERR => "debug");
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list