summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLUtils.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/TeXLive/TLUtils.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm57
1 files changed, 49 insertions, 8 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index 60fbc37fb3a..75c7c394498 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -60,7 +60,7 @@ C<TeXLive::TLUtils> -- Utilities used in the TeX Live Infrastructure Modules
TeXLive::TLUtils::sort_uniq(@list);
TeXLive::TLUtils::push_uniq(\@list, @items);
TeXLive::TLUtils::member($item, @list);
- TeXLive::TLUtils::debug($string);
+ TeXLive::TLUtils::tllog($level, $string);
TeXLive::TLUtils::kpsewhich;
=head1 DESCRIPTION
@@ -70,7 +70,7 @@ C<TeXLive::TLUtils> -- Utilities used in the TeX Live Infrastructure Modules
BEGIN {
use Exporter ();
- use vars qw( @ISA @EXPORT_OK );
+ use vars qw( @ISA @EXPORT_OK @EXPORT);
@ISA = qw(Exporter);
@EXPORT_OK = qw(
&platform
@@ -100,10 +100,10 @@ BEGIN {
&sort_uniq
&push_uniq
&member
- &debug
&kpsewhich
&quotewords
);
+ @EXPORT = qw(tllog);
}
@@ -1078,17 +1078,58 @@ sub member {
=pod
-=item C<debug($string, ...)>
+=item C<tllog($type, $rest, ...)>
-The C<debug> function echos the argument strings to STDERR if
-the global variable C<opt_debug> is set.
+Debugging output is controlled by 2 global variables: $::LOGLEVELTERMINAL
+for the output to the terminal, and $::LOGLEVELFILE for the output to
+the log file (whose filehandle should be saved in $::LOGFILE).
+
+If the first argument of C<tllog> is less or equal to the respective
+threshold the message is issued to STDERR and log file, respectively.
+
+If $::LOGFILE is not defined logging to a log file is completely disabled.
+
+Predefined levels of debugging are: $::LOG_NORMAL, $::LOG_DEBUG, $::LOG_DDEBUG,
+and $::LOG_DDDEBUG with increasing level of detailedness.
+
+Note that all TeXLive modules to logging with $::LOG_DDDEBUG!
+
+By default the threshold for logging to the log file is $::LOG_DEBUG, and
+the one for the terminal $::LOG_NORMAL.
+
+If you want to disable logging set the respective thershold to $::LOG_ZERO.
=cut
-sub debug {
- print STDERR "tldbg: @_\n" if $::opt_debug;
+$::LOG_ZERO = -1;
+$::LOG_NORMAL = 0;
+$::LOG_DEBUG = 1;
+$::LOG_DDEBUG = 2;
+$::LOG_DDDEBUG = 3;
+if (!defined($::LOGLEVELFILE)) {
+ $::LOGLEVELFILE = $::LOG_DEBUG;
+}
+if (!defined($::LOGLEVELTERMINAL)) {
+ $::LOGLEVELTERMINAL = $::LOG_NORMAL;
+}
+
+sub tllog {
+ my ($imp, @rest) = @_;
+ if (defined($::LOGFILE)) {
+ _tllog($::LOGLEVELFILE,$::LOGFILE,$imp,"tllog: ",@rest);
+ }
+ my $stderr = \*STDERR;
+ _tllog($::LOGLEVELTERMINAL,$stderr,$imp,"tllog: ",@rest);
}
+sub _tllog {
+ my ($threshold,$output,$imp, @rest) = @_;
+ if ($imp <= $threshold) {
+ print $output "@rest";
+ }
+}
+
+
=pod
=item C<kpsewhich($varname)>