texlive[55369] Master/texmf-dist/scripts/texlive/tlmgr.pl: tlmgr: log

commits+preining at tug.org commits+preining at tug.org
Mon Jun 1 02:32:01 CEST 2020


Revision: 55369
          http://tug.org/svn/texlive?view=revision&revision=55369
Author:   preining
Date:     2020-06-01 02:32:00 +0200 (Mon, 01 Jun 2020)
Log Message:
-----------
tlmgr: log command output to separate file

Modified Paths:
--------------
    trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl

Modified: trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl	2020-05-31 21:31:15 UTC (rev 55368)
+++ trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl	2020-06-01 00:32:00 UTC (rev 55369)
@@ -25,6 +25,7 @@
 our $loadmediasrcerror;
 our $packagelogfile;
 our $packagelogged;
+our $commandlogfile;
 our $tlmgr_config_file;
 our $pinfile;
 our $action; # for the pod2usage -sections call
@@ -358,6 +359,7 @@
   "machine-readable" => 1,
   "no-execute-actions" => 1,
   "package-logfile" => "=s",
+  "command-logfile" => "=s",
   "persistent-downloads" => "!",
   "pause" => 1,
   "pin-file" => "=s",
@@ -653,6 +655,22 @@
     debug("appending to package log file: $packagelogfile\n");
   }
 
+  # output of executed commands are put into -command-logfile
+  $commandlogfile = $opts{"command-logfile"};
+  if ($opts{"usermode"}) {
+    $commandlogfile ||= "$::maintree/web2c/tlmgr-commands.log";
+  } else {
+    $commandlogfile ||= "$texmfsysvar/web2c/tlmgr-commands.log";
+  }
+  # Try to open the packagelog file, but do NOT die when that does not work
+  if (!open(COMMANDLOG, ">>$commandlogfile")) {
+    debug("Cannot open command log file for appending: $commandlogfile\n");
+    debug("Will not log output of executed commands for this run\n");
+    $commandlogfile = "";
+  } else {
+    debug("appending to command log file: $commandlogfile\n");
+  }
+
   $loadmediasrcerror = "Cannot load TeX Live database from ";
 
   # load the config file and set the config options
@@ -815,7 +833,7 @@
   # tlmgr front ends (MacOSX's TeX Live Utility) can read it
   # and show it to the user before the possibly long delay.
   info("running $cmd ...\n");
-  logpackage("running $cmd");
+  logcommand("running $cmd");
   my ($out, $ret);
   if ($opts{"dry-run"}) {
     $ret = $F_OK;
@@ -829,22 +847,17 @@
   } else {
     ($out, $ret) = TeXLive::TLUtils::run_cmd("$cmd 2>&1");
   }
-  # Although it is quite verbose to report all the output from every
-  # fmtutil (especially) run, it's the only way to know what's normal
-  # when something fails. Prefix each line to make them easy to see
-  # (and filter out/in).
-  (my $prefixed_out = $out) =~ s/^/(cmd)/gm;
-  $prefixed_out =~ s/\n+$//; # trailing newlines don't seem interesting
-  my $outmsg = "output:\n$prefixed_out\n--end of output of $cmd.\n";
+  $out =~ s/\n+$//; # trailing newlines don't seem interesting
+  my $outmsg = "output:\n$out\n--end of output of $cmd.\n";
   if ($ret == $F_OK) {
     info("done running $cmd.\n");
-    logpackage("success, $outmsg");
+    logcommand("success, $outmsg");
     ddebug("$cmd $outmsg");
     return ($F_OK);
   } else {
     info("\n");
     tlwarn("$prg: $cmd failed (status $ret), output:\n$out\n");
-    logpackage("error, status: $ret, $outmsg");
+    logcommand("error, status: $ret, $outmsg");
     return ($F_ERROR);
   }
 }
@@ -7457,7 +7470,14 @@
     print PACKAGELOG "[$tim] @_\n";
   }
 }
+sub logcommand {
+  if ($commandlogfile) {
+    my $tim = localtime();
+    print COMMANDLOG "[$tim] @_\n";
+  }
+}
 
+
 # resolve relative paths from tlpdb wrt tlroot 
 sub norm_tlpdb_path {
   my ($path) = @_;
@@ -7805,6 +7825,13 @@
 
 tlshell shares its message catalog with tlmgr.
 
+=item B<--command-logfile> I<file>
+
+C<tlmgr> logs the output of all programs invoked (mktexlr, mtxrun, fmtutil,
+updmap) to a separate log file, by default
+C<TEXMFSYSVAR/web2c/tlmgr-commands.log>.  This option allows you to specify a
+different file for the log.
+
 =item B<--debug-translation>
 
 In GUI mode, this switch tells C<tlmgr> to report any untranslated (or



More information about the tex-live-commits mailing list.