]> git.donarmstrong.com Git - perltidy.git/commitdiff
only save logfile when specifically requested
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 16 Nov 2022 16:40:19 +0000 (08:40 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 16 Nov 2022 16:40:19 +0000 (08:40 -0800)
Previously, a logfile might also be saved if the code detected
an internal bug. The chance of this is now close to zero, and the user
can always rerun to get a log if necessary.

lib/Perl/Tidy.pm
lib/Perl/Tidy/Logger.pm

index 1fd935a922cab67f81c1690feeb2d13f5f90a24e..865d918e4663b5167aadaee502ca024268404e8d 100644 (file)
@@ -1984,6 +1984,8 @@ EOM
         my $log_file = $fileroot . $dot . "LOG";
         if ($logfile_stream) { $log_file = $logfile_stream }
 
+        # The logger object handles warning messages, logfile messages,
+        # and can supply basic run information to lower level routines.
         my $logger_object = Perl::Tidy::Logger->new(
             rOpts           => $rOpts,
             log_file        => $log_file,
index f1c43860d03895d12a6b8fea231772028acbfebd..a47a9eb4377fab881d8b170b467b1e88dc5e35e8 100644 (file)
@@ -1,6 +1,7 @@
 #####################################################################
 #
-# The Perl::Tidy::Logger class writes the .LOG and .ERR files
+# The Perl::Tidy::Logger class writes any .LOG and .ERR files
+# and supplies some basic run information for error handling.
 #
 #####################################################################
 
@@ -100,11 +101,12 @@ sub new {
         _warning_count                 => 0,
         _complaint_count               => 0,
         _is_encoded_data               => $is_encoded_data,
-        _saw_code_bug      => -1,                   # -1=no 0=maybe 1=for sure
+        _saw_code_bug      => -1,                    # -1=no 0=maybe 1=for sure
         _saw_brace_error   => 0,
         _output_array      => [],
         _input_stream_name => $input_stream_name,
         _filename_stamp    => $filename_stamp,
+        _save_logfile      => $rOpts->{'logfile'},
     }, $class;
 }
 
@@ -448,12 +450,10 @@ sub report_definite_bug {
 
 sub get_save_logfile {
 
-    # To be called after tokenizer has finished to make formatting more
-    # efficient.
-    my $self         = shift;
-    my $saw_code_bug = $self->{_saw_code_bug};
-    my $rOpts        = $self->{_rOpts};
-    return $saw_code_bug == 1 || $rOpts->{'logfile'};
+    # Returns a true/false flag indicating whether or not
+    # the logfile will be saved.
+    my $self = shift;
+    return $self->{_save_logfile};
 }
 
 sub finish {
@@ -461,13 +461,11 @@ sub finish {
     # called after all formatting to summarize errors
     my ($self) = @_;
 
-    my $rOpts         = $self->{_rOpts};
     my $warning_count = $self->{_warning_count};
     my $saw_code_bug  = $self->{_saw_code_bug};
+    my $save_logfile  = $self->{_save_logfile};
+    my $log_file      = $self->{_log_file};
 
-    my $save_logfile = $saw_code_bug == 1
-      || $rOpts->{'logfile'};
-    my $log_file = $self->{_log_file};
     if ($warning_count) {
         if ($save_logfile) {
             $self->block_log_output();    # avoid echoing this to the logfile