File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -1145,11 +1145,11 @@ def complete(self, graceful=None):
11451145 os .makedirs (plog )
11461146 # Append to the file
11471147 flog = None
1148+ timestamp = None
11481149 try :
1149- # Add a timestamp if the file is not empty to distinguish logs
1150- timestamp = None
11511150 flog = plog if not isinstance (plog , str ) else open (plog , 'a' )
1152- if os .fstat (flog .fileno ()).st_size :
1151+ # Add a timestamp if the file is not empty to distinguish logs
1152+ if isinstance (plog , str ) and os .fstat (flog .fileno ()).st_size :
11531153 if timestamp is None :
11541154 timestamp = time .gmtime ()
11551155 except IOError as err :
@@ -1160,7 +1160,8 @@ def complete(self, graceful=None):
11601160 if pout is self .pipedout :
11611161 flog = sys .stdout
11621162 try :
1163- print (timeheader (timestamp ), file = flog ) # Note: prints also newline unlike flog.write()
1163+ if timestamp is not None :
1164+ print (timeheader (timestamp ), file = flog ) # Note: prints also newline unlike flog.write()
11641165 flog .write (pout ) # Write the piped output
11651166 except IOError as err :
11661167 print ('ERROR on logging piped data "{}" for "{}": {}'
You can’t perform that action at this time.
0 commit comments