File tree 1 file changed +5
-4
lines changed
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):
1145
1145
os .makedirs (plog )
1146
1146
# Append to the file
1147
1147
flog = None
1148
+ timestamp = None
1148
1149
try :
1149
- # Add a timestamp if the file is not empty to distinguish logs
1150
- timestamp = None
1151
1150
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 :
1153
1153
if timestamp is None :
1154
1154
timestamp = time .gmtime ()
1155
1155
except IOError as err :
@@ -1160,7 +1160,8 @@ def complete(self, graceful=None):
1160
1160
if pout is self .pipedout :
1161
1161
flog = sys .stdout
1162
1162
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()
1164
1165
flog .write (pout ) # Write the piped output
1165
1166
except IOError as err :
1166
1167
print ('ERROR on logging piped data "{}" for "{}": {}'
You can’t perform that action at this time.
0 commit comments