Francois Gouget : testbot: SetupRedirects() should not depend on prior logging.
Alexandre Julliard
julliard at winehq.org
Tue Sep 24 11:41:03 CDT 2019
Module: tools
Branch: master
Commit: b360a0b5e2b0099e8ba3b326ccb9905aa3d4ff6a
URL: https://source.winehq.org/git/tools.git/?a=commit;h=b360a0b5e2b0099e8ba3b326ccb9905aa3d4ff6a
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Tue Sep 24 11:00:15 2019 +0200
testbot: SetupRedirects() should not depend on prior logging.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
testbot/lib/WineTestBot/Log.pm | 59 +++++++++++++++++++++---------------------
1 file changed, 30 insertions(+), 29 deletions(-)
diff --git a/testbot/lib/WineTestBot/Log.pm b/testbot/lib/WineTestBot/Log.pm
index c39a557..7ac4dab 100644
--- a/testbot/lib/WineTestBot/Log.pm
+++ b/testbot/lib/WineTestBot/Log.pm
@@ -33,26 +33,28 @@ use WineTestBot::Config;
my $logfile;
my $logprefix;
-sub LogMsg(@)
+sub SetupLogging()
{
- if (!defined $logfile)
+ require File::Basename;
+ $logprefix = File::Basename::basename($0);
+ $logprefix =~ s/\.[^.]*$//;
+ my $oldumask = umask(002);
+ if (!open($logfile, ">>", "$LogDir/log"))
{
- require File::Basename;
- $logprefix = File::Basename::basename($0);
- $logprefix =~ s/\.[^.]*$//;
- my $oldumask = umask(002);
- if (!open($logfile, ">>", "$LogDir/log"))
- {
- print STDERR "$logprefix:warning: could not open '$LogDir/log' for writing: $!\n";
- open($logfile, ">>&=", 2);
- }
- umask($oldumask);
-
- # Flush after each print
- my $tmp=select($logfile);
- $| = 1;
- select($tmp);
+ print STDERR "$logprefix:warning: could not open '$LogDir/log' for writing: $!\n";
+ open($logfile, ">>&=", 2);
}
+ umask($oldumask);
+
+ # Flush after each print
+ my $tmp=select($logfile);
+ $| = 1;
+ select($tmp);
+}
+
+sub LogMsg(@)
+{
+ SetupLogging() if (!defined $logfile);
print $logfile scalar localtime, " ", $logprefix, "[$$]: ", @_ if ($logfile);
}
@@ -75,19 +77,18 @@ exec()-ing external tools so their error messages are not lost.
sub SetupRedirects()
{
- if (defined $logfile)
+ SetupLogging() if (!defined $logfile);
+
+ if (open(STDERR, ">>&", $logfile))
+ {
+ # Make sure stderr still flushes after each print
+ my $tmp = select(STDERR);
+ $| = 1;
+ select($tmp);
+ }
+ else
{
- if (open(STDERR, ">>&", $logfile))
- {
- # Make sure stderr still flushes after each print
- my $tmp=select(STDERR);
- $| = 1;
- select($tmp);
- }
- else
- {
- LogMsg "unable to redirect stderr to '$logfile': $!\n";
- }
+ LogMsg "unable to redirect stderr to '$logfile': $!\n";
}
}
More information about the wine-cvs
mailing list