Skip to content

Commit

Permalink
log file process will no longer cause script to fail if the log file …
Browse files Browse the repository at this point in the history
…can not be opened: #145
  • Loading branch information
cmhughes committed Apr 24, 2021
1 parent 3f6f22a commit da2b15e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
17 changes: 10 additions & 7 deletions LatexIndent/Document.pm
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,18 @@ sub output_indented_text{
# open log file
my $logfileName = $switches{logFileName}||"indent.log";
my $logfile;
open($logfile,">","${$self}{cruftDirectory}/$logfileName") or die "Can't open $logfileName";
my $logfilePossible = 1;
open($logfile,">","${$self}{cruftDirectory}/$logfileName") or $logfilePossible =0;

foreach my $line (@{LatexIndent::Logger::logFileLines}){
print $logfile $line,"\n";
}
if($logfilePossible){
foreach my $line (@{LatexIndent::Logger::logFileLines}){
print $logfile $line,"\n";
}

# close log file
close($logfile);
}

# close log file
close($logfile);

# output to screen, unless silent mode
print ${$self}{body} unless $switches{silentMode};

Expand Down
3 changes: 2 additions & 1 deletion documentation/sec-default-user-local.tex
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ \section{defaultSettings.yaml}\label{sec:defuseloc}
%(*@@*)\end{noindent}
\end{cmhlistings}

Important note: it is assumed that the \texttt{noindent} block statements appear on their own line.
Important note: it is assumed that the \texttt{noindent} block statements appear on
their own line.

\yamltitle{removeTrailingWhitespace}*{fields}\label{yaml:removeTrailingWhitespace}

Expand Down
8 changes: 8 additions & 0 deletions documentation/sec-how-to-use.tex
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,14 @@ \subsection{From the command line}\label{sec:commandline}
if you wish to change the name of this file, simply call the script with your chosen name
after the \texttt{-g} switch as demonstrated above.

\announce{new}{log file updated} If \texttt{latexindent.pl} can not open the log file that you
specify, then the script
will operate, and no log file will be produced; this might be helpful to users who wish
to specify the following, for example
\begin{commandshell}
latexindent.pl -g /dev/null myfile.tex
\end{commandshell}

\flagbox{-sl, --screenlog}
\index{switches!-sl, --screenlog definition and details}
\begin{commandshell}
Expand Down

0 comments on commit da2b15e

Please sign in to comment.