summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/TeXLive')
-rw-r--r--Master/tlpkg/TeXLive/TLPDB.pm8
-rw-r--r--Master/tlpkg/TeXLive/TLPOBJ.pm6
-rw-r--r--Master/tlpkg/TeXLive/TLPSRC.pm3
-rw-r--r--Master/tlpkg/TeXLive/TLTREE.pm10
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm57
5 files changed, 63 insertions, 21 deletions
diff --git a/Master/tlpkg/TeXLive/TLPDB.pm b/Master/tlpkg/TeXLive/TLPDB.pm
index 007dc3477d3..74b18051218 100644
--- a/Master/tlpkg/TeXLive/TLPDB.pm
+++ b/Master/tlpkg/TeXLive/TLPDB.pm
@@ -51,7 +51,7 @@ C<TeXLive::TLPDB> -- A database of TeX Live Packages
use TeXLive::TLConfig qw($CategoriesRegexp $DefaultCategory $InfraLocation
$DatabaseName);
-use TeXLive::TLUtils qw(dirname mkdirhier);
+use TeXLive::TLUtils qw(dirname mkdirhier tllog);
use TeXLive::TLPOBJ;
my $_listdir;
@@ -134,7 +134,7 @@ sub from_file {
my $found = 0;
do {
my $tlp = TeXLive::TLPOBJ->new;
- &TeXLive::TLUtils::debug("creating tlp from $path...");
+ tllog($::LOG_DDDEBUG, "creating tlp from $path...\n");
$found = $tlp->from_fh(\*TMP,1);
if ($found) {
$self->add_tlpobj($tlp);
@@ -157,8 +157,8 @@ sub writeout {
my $self = shift;
my $fd = (@_ ? $_[0] : STDOUT);
foreach (sort keys %{$self->{'tlps'}}) {
- &TeXLive::TLUtils::debug("tlpname = $_");
- &TeXLive::TLUtils::debug("foo: " . $self->{'tlps'}{$_}->name);
+ tllog($::LOG_DDDEBUG, "tlpname = $_\n");
+ tllog($::LOG_DDDEBUG, "foo: ", $self->{'tlps'}{$_}->name, "\n");
$self->{'tlps'}{$_}->writeout($fd);
print $fd "\n";
}
diff --git a/Master/tlpkg/TeXLive/TLPOBJ.pm b/Master/tlpkg/TeXLive/TLPOBJ.pm
index 2c9586ff775..bb2fd061aa9 100644
--- a/Master/tlpkg/TeXLive/TLPOBJ.pm
+++ b/Master/tlpkg/TeXLive/TLPOBJ.pm
@@ -65,7 +65,7 @@ sub from_fh {
#while (my $line = $fh->getline) {
while (my $line = <$fh>) {
chomp($line);
- &TeXLive::TLUtils::debug("reading line: >>>$line<<<");
+ tllog($::LOG_DDDEBUG, "reading line: >>>$line<<<\n");
$line =~ /^\s*#/ && next; # skip comment lines
if ($line =~ /^\s*$/) {
if (!$started) { next; }
@@ -568,7 +568,7 @@ sub make_container {
die("Container method $type unknown!\n");
}
unlink("$destdir/$containername");
- print "$compresscmd\n" if ($::opt_debug);
+ tllog($::LOG_DDDEBUG, "$compresscmd\n");
open ZIP, $compresscmd or die "Cannot open container program $compresscmd: $!\n";
map {
if (! -f $_) {
@@ -582,7 +582,7 @@ sub make_container {
unlink("$tlpobjdir/$self->{'name'}.tlpobj");
rmdir("$tlpobjdir") if $removetlpobjdir;
chdir($cwd);
- print "Done $containername\n" if ($::opt_debug);
+ tllog($::LOG_DDDEBUG, "Done $containername\n");
}
diff --git a/Master/tlpkg/TeXLive/TLPSRC.pm b/Master/tlpkg/TeXLive/TLPSRC.pm
index 0821aef04cf..505d90196bd 100644
--- a/Master/tlpkg/TeXLive/TLPSRC.pm
+++ b/Master/tlpkg/TeXLive/TLPSRC.pm
@@ -9,6 +9,7 @@ package TeXLive::TLPSRC;
use FileHandle;
use TeXLive::TLConfig qw($CategoriesRegexp);
+use TeXLive::TLUtils qw(tllog);
use TeXLive::TLPOBJ;
use TeXLive::TLTREE;
@@ -115,7 +116,7 @@ sub from_file
push @depends, "$1" if ("$1" ne "");
next;
} else {
- warn "$srcfile: unknown tlpsrc directive, please fix: $line\n";
+ tllog($::LOG_NORMAL,"$srcfile: unknown tlpsrc directive, please fix: $line\n");
}
}
}
diff --git a/Master/tlpkg/TeXLive/TLTREE.pm b/Master/tlpkg/TeXLive/TLTREE.pm
index a1cbb4279f7..7b9c70d7abc 100644
--- a/Master/tlpkg/TeXLive/TLTREE.pm
+++ b/Master/tlpkg/TeXLive/TLTREE.pm
@@ -219,7 +219,7 @@ sub _get_matching_files {
} else {
die "Unknown pattern $p";
}
- TeXLive::TLUtils::debug("p=$p; matchfiles=@matchfiles");
+ tllog($::LOG_DDDEBUG, "p=$p; matchfiles=@matchfiles\n");
return @matchfiles;
}
@@ -245,9 +245,9 @@ sub _get_files_matching_glob_pattern {
return unless (defined($self->{'_filesofdir'}{$dirpart}));
my @candfiles = @{$self->{'_filesofdir'}{$dirpart}};
foreach my $f (@candfiles) {
- &TeXLive::TLUtils::debug("matching $f in $dirpart via glob $globline");
+ tllog($::LOG_DDDEBUG, "matching $f in $dirpart via glob $globline\n");
if ($f =~ /^$basepart$/) {
- &TeXLive::TLUtils::debug("hit: globline=$globline, $dirpart/$f");
+ tllog($::LOG_DDDEBUG, "hit: globline=$globline, $dirpart/$f\n");
if ("$dirpart" eq ".") {
push @returnfiles, "$f";
} else {
@@ -258,9 +258,9 @@ sub _get_files_matching_glob_pattern {
if ($dirpart =~ m@^bin/win32@) {
# for arch=win32 under bin we also want to match .dll, .bat, .exe files
foreach my $f (@candfiles) {
- &TeXLive::TLUtils::debug("matching $f in $dirpart via glob $globline.{bat/exe}");
+ tllog($::LOG_DDDEBUG, "matching $f in $dirpart via glob $globline.{bat/exe}\n");
if ($f =~ /^$basepart\.(bat|exe|dll)$/) {
- &TeXLive::TLUtils::debug("hit: globline=$globline, $dirpart/$f");
+ tllog($::LOG_DDDEBUG, "hit: globline=$globline, $dirpart/$f\n");
if ("$dirpart" eq ".") {
push @returnfiles, "$f";
} else {
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)>