Emit stack backtrace if syslog call fails
authorJacob Bachmeyer <jcb@gnu.org>
Fri, 7 Oct 2022 04:12:59 +0000 (23:12 -0500)
committerJacob Bachmeyer <jcb@gnu.org>
Fri, 7 Oct 2022 04:12:59 +0000 (23:12 -0500)
gatekeeper.pl

index 445d0eadd4050f15efa35ed434ef8e3fde3b20d3..b0d2969bf09eeb71e6a50917d83c69826d346f04 100755 (executable)
@@ -106,6 +106,8 @@ use warnings;
 
 use constant ();       # load this now for use in later BEGIN blocks
 
+use Carp qw(cluck);    # for stack trace on error in ftp_syslog
+
 use FindBin;
 use File::Spec;
 
@@ -349,13 +351,10 @@ sub ftp_syslog {
 
   # The syslog function is pretty picky, and (sometimes) dies silently
   # when using non-valid syslog priorities.
-  # That's why we run it inside an eval, and print out any errors to STDERR.
-  eval {
-    syslog($priority, $message);
-  };
-  if ($@) {
-    print STDERR "$@\n";
-  }
+  # That's why we run it inside an eval, with errors printed to STDERR,
+  # complete with stack backtrace.
+  eval { syslog($priority, $message) };
+  cluck($@) if $@;
 }
 
 sub ftp_warn($) {