Commit 413d322c authored by Stefan Tauner's avatar Stefan Tauner
Browse files

Logging: use Log::Dispatch::FileRotate to rotate FIJI log files

Files will be rotated once a day or if they grow to 100 MB up to 7 stages.

 - add new log files to .gitignore
 - refine documentation and install scripts
 - refine log level of "Starting/stopping execution..." to become visible
   in rotated logs
 - minor other log refinements
parent 98a51b34
*.log
*.log.*
*.bak
*~
builds/
......
......@@ -201,8 +201,6 @@ sub generate_constraints {
my $synhash = $syn_toolhash->{$synthesis_tool};
my $prhash = $pr_toolhash->{$pr_tool};
$logger->info("Generating constraints for $synthesis_tool/$pr_tool.");
return "No entries for synthesis tool found" if (!defined $synhash);
return "No entries for P&R tool found" if (!defined $prhash);
......
......@@ -51,6 +51,11 @@ sub main {
Log::Log4perl::init_and_watch($log_conf, 'HUP');
FIJI::Utils::increase_verbosity($cfg->{'verbosity_delta'});
my $logger = get_logger("");
my $name = $0;
$name =~ s/\.p[lm]//;
$logger->info("=== Starting new execution of $name ===");
$logger->info(sprintf("%d argument(s)%s", scalar(@_), scalar(@_) > 0 ? ": @_" : ""));
my ($cfg,$prob,$dur) = @_;
pod2usage(0) if (defined $cfg->{'help'});
......@@ -142,7 +147,7 @@ sub main {
_ask_save($cfg, TB, $faulty_tests, $fiji_downloader, $time);
}
$logger->trace("=== Stopping execution ===");
$logger->info("=== Stopping execution ===");
return 0;
}
......
......@@ -190,8 +190,8 @@ sub main {
my $ret = 0;
my $verbosity_delta = 0;
$name =~ s/\.p[lm]//;
$logger->debug("=== Starting new execution of $name ===");
$logger->debug(sprintf("%d argument(s)%s", scalar(@_), scalar(@_) > 0 ? ": @_" : ""));
$logger->info("=== Starting new execution of $name ===");
$logger->info(sprintf("%d argument(s)%s", scalar(@_), scalar(@_) > 0 ? ": @_" : ""));
my ($settings_filename, $tests_filename, $help);
......@@ -345,7 +345,7 @@ sub main {
bailout:
$self->_cleanup();
$logger->trace("=== Stopping execution ===");
$logger->info("=== Stopping execution ===");
return $ret;
}
......
......@@ -64,8 +64,8 @@ sub log_start {
my $name = basename($0);
$name =~ s/\.p[lm]//;
my $logger = get_logger("");
$logger->debug("=== Starting new execution of $name ===");
$logger->debug(sprintf("%d argument(s)%s", scalar(@argv), scalar(@argv) > 0 ? ": @argv" : ""));
$logger->info("=== Starting new execution of $name ===");
$logger->info(sprintf("%d argument(s)%s", scalar(@argv), scalar(@argv) > 0 ? ": @argv" : ""));
}
# Filter file line by line and stuff result into $ctx->addfile.
......@@ -176,9 +176,9 @@ sub main {
my $custom_file_appender = Log::Log4perl::Appender->new(
"Log::Log4perl::Appender::File",
name => "custom_file_log",
Threshold => "TRACE",
filename => $logfile_path,
);
$custom_file_appender->threshold("INFO");
my $layout = $file_appender->{'layout'};
$custom_file_appender->layout(clone($layout));
......@@ -186,7 +186,7 @@ sub main {
foreach my $a (values %{Log::Log4perl->appenders()}) {
if ($a->name eq "logfile") {
$logger->info("Switching from initial log file to custom log file " . $custom_file_appender->filename);
unlink($a->filename);
# unlink($a->{'appender'}->{'LDF'}->{'filename'}); # Remove initial log file
Log::Log4perl->eradicate_appender($a->name);
next;
}
......@@ -429,7 +429,7 @@ sub main {
return 1;
}
$logger->debug("=== Stopping execution ===");
$logger->info("=== Stopping execution ===");
return 0;
}
......
......@@ -76,8 +76,8 @@ sub main {
my @ARGV = @_;
my $verbosity_delta = 0;
$name =~ s/\.p[lm]//;
$logger->debug("=== Starting new execution of $name ===");
$logger->debug(sprintf("%d argument(s)%s", scalar(@_), scalar(@_) > 0 ? ": @_" : ""));
$logger->info("=== Starting new execution of $name ===");
$logger->info(sprintf("%d argument(s)%s", scalar(@_), scalar(@_) > 0 ? ": @_" : ""));
my ($settings_filename, $netlist_filename, $help);
......@@ -182,7 +182,7 @@ sub main {
bailout:
$self->_cleanup();
$logger->trace("=== Stopping execution ===");
$logger->info("=== Stopping execution ===");
return $rv if defined $rv;
return 0;
}
......
......@@ -19,7 +19,7 @@
:: There is in theory a batch file that does that temporarily but its
:: path is not constant between VS versions...
:: This work would never been possible without stackexchange (is that a
:: This work would have never been possible without stackexchange (is that a
:: good thing?).
:: http://stackoverflow.com/questions/8493493/how-to-loop-through-tokens-in-a-string
:: http://stackoverflow.com/questions/3294599/do-batch-files-support-multiline-variables
......@@ -38,6 +38,7 @@ Digest::CRC ^
Doxygen::Filter::Perl ^
enum ^
Log::Dispatch::Output ^
Log::Dispatch::FileRotate ^
Log::Log4perl ^
Params::Validate ^
Scalar::Util ^
......
......@@ -22,6 +22,7 @@ Digest::CRC
Doxygen::Filter::Perl
enum
Log::Dispatch::Output
Log::Dispatch::FileRotate
Log::Log4perl
Params::Validate
Scalar::Util
......
......@@ -17,10 +17,14 @@ log4perl.appender.string.Threshold = INFO
log4perl.appender.string.layout = ${layout_class}
log4perl.appender.string.layout.ConversionPattern = ${layout_pattern_short}
log4perl.appender.logfile = Log::Log4perl::Appender::File
log4perl.appender.logfile = Log::Dispatch::FileRotate
log4perl.appender.logfile.Threshold = INFO
log4perl.appender.logfile.filename = sub { $0 =~ s/.pl/.log/r; }
log4perl.appender.logfile.max = 7
log4perl.appender.logfile.check_both = 1
log4perl.appender.logfile.size = 100*1024*1024
log4perl.appender.logfile.DatePattern = yyyy-MM-dd
log4perl.appender.logfile.mode = append
log4perl.appender.Logfile.syswrite = 1
log4perl.appender.logfile.syswrite = 1
log4perl.appender.logfile.layout = ${layout_class}
log4perl.appender.logfile.layout.ConversionPattern = ${layout_pattern}
......@@ -41,6 +41,7 @@ which can be found in \Cref{tab:perlmod}.
Digest::CRC & CRC calculation & \textit{Instrument}, \textit{\acs{FIJIEE}} \\
Doxygen::Filter::Perl & Doxygen documentation & For documentation only \\
Log::Log4Perl & Logging framework & All tools \\
Log::Dispatch::FileRotate & Automatic log rotation & All tools \\
Log::Dispatch::Output & Base for custom log appenders & \textit{\acs{FIJIEE} GUI} \\
Params::Validate & Validation of parameters & \textit{\acs{FIJIEE} GUI} \\
Scalar::Util & Various numeric helpers & All tools \\
......@@ -100,6 +101,7 @@ After that the following Perl packages remain to be installed from CPAN:
\begin{itemize}
\item enum
\item Log::Dispatch::Output
\item Log::Dispatch::FileRotate
\item Config::Simple
\item Digest::CRC
\item Doxygen::Filter::Perl
......@@ -109,7 +111,7 @@ After that the following Perl packages remain to be installed from CPAN:
That can be handled with the following command within a Cygwin shell.
\begin{lstlisting}
perl -MCPAN -e "CPAN::Shell->notest('install', 'enum', 'Log::Dispatch::Output', 'Config::Simple', 'Digest::CRC', 'Doxygen::Filter::Perl', 'Sort::Naturally', 'Tk::StatusBar')"
perl -MCPAN -e "CPAN::Shell->notest('install', 'enum', 'Log::Dispatch::Output', 'Log::Dispatch::FileRotate', 'Config::Simple', 'Digest::CRC', 'Doxygen::Filter::Perl', 'Sort::Naturally', 'Tk::StatusBar')"
\end{lstlisting}
Finally, you need also to install Verilog-Perl as shown in \Cref{sec:verilog-perl-install}.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment