From: Jacob Bachmeyer Date: Tue, 1 Nov 2022 03:50:26 +0000 (-0500) Subject: Add infrastructure to support logging current processing phase X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a65f68812fb2517874e827569c0a3db2137355a8;p=gatekeeper.git Add infrastructure to support logging current processing phase This also collects the definition of $Log_Style to the Logging group in preparation for future documentation improvements. --- diff --git a/gatekeeper.pl b/gatekeeper.pl index 19bf737..a23535e 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -309,12 +309,6 @@ my $email_blacklist = "/home/gatekpr/etc/email_blacklist"; # List of all package maintainers my $maintainers_bypkg = "/home/gatekpr/etc/maintainers.bypkg"; -{ - our $Log_Style = 'GNU'; - $Log_Style = 'Alpha' if ($style eq 'alpha'); - $Log_Style = 'Distros' if ($style eq 'distros'); -} - # maintainer e-mail address my $maintainer_email = "ftp-upload-report\@gnu.org"; @@ -363,8 +357,6 @@ if (IN_TEST_MODE) { # override the above for testing # verify configuration for mock syslog die "gatekeeper: test mode: TEST_SYSLOG_SOCKET not valid" unless $ENV{TEST_SYSLOG_SOCKET} && -S $ENV{TEST_SYSLOG_SOCKET} && -w _; - # override log message tag - our $Log_Style = 'Test'; } else { # in production mode # ensure we are using the real gpgv open my $gpgv,'-|',GPGV_BIN, '--version' @@ -393,19 +385,45 @@ gatekeeper itself and these functions may change without notice. # - Logging # +{ + # To identify which zone is being processed, ftp_syslog will prepend + # this, inside parentheses, to all messages logged. + if (IN_TEST_MODE) { + # override log message tag + our $Log_Style = 'Test'; + } else { + our $Log_Style = 'GNU'; + $Log_Style = 'Alpha' if ($style eq 'alpha'); + $Log_Style = 'Distros' if ($style eq 'distros'); + } + + # If this is set to a defined value, ftp_syslog will prepend it, inside + # square brackets, to all messages logged. + our $Phase = undef; # should be set using local + + # If this is set to a defined value, ftp_abort will write the message + # here instead of using syslog. + our $AbortPipe = undef; + # This selects the default exit code, if no code is specified. + our $AbortExitCode = 1; +} + sub ftp_syslog { my $priority = shift; my $message = shift; - our $Log_Style; + our $Log_Style; our $Phase; # Remove a trailing newline $message =~ s/[\r\n]+$//; # Collapse the message to a single line for syslog $message =~ s/[\r\n]+/ \/ /g; + # Prepend the current phase, if set + $message = '['.$Phase.'] '.$message if defined $Phase; + # Prepend the log style tag - $message = "($Log_Style) ".$message; + $message = '('.$Log_Style.') '.$message; # The syslog function is pretty picky, and (sometimes) dies silently # when using non-valid syslog priorities. @@ -415,14 +433,6 @@ sub ftp_syslog { cluck($@) if $@; } -{ - # If this is set to a defined value, ftp_abort will write the message - # here instead of using syslog. - our $AbortPipe = undef; - # This selects the default exit code, if no code is specified. - our $AbortExitCode = 1; -} - sub ftp_abort($;$) { my $msg = shift; my $exitcode = shift;