mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Fix line buffering on windows in the RotatingLog
This commit is contained in:
parent
3a38646756
commit
9c82b810db
@ -309,7 +309,7 @@ class RotatingStream(object):
|
|||||||
self.set_output()
|
self.set_output()
|
||||||
|
|
||||||
def set_output(self):
|
def set_output(self):
|
||||||
self.stream = share_open(self.filename, 'ab', 1) # line buffered
|
self.stream = share_open(self.filename, 'ab', -1 if iswindows else 1) # line buffered
|
||||||
try:
|
try:
|
||||||
self.current_pos = self.stream.tell()
|
self.current_pos = self.stream.tell()
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
@ -324,6 +324,11 @@ class RotatingStream(object):
|
|||||||
kwargs['safe_encode'] = True
|
kwargs['safe_encode'] = True
|
||||||
kwargs['file'] = self.stream
|
kwargs['file'] = self.stream
|
||||||
self.current_pos += prints(*args, **kwargs)
|
self.current_pos += prints(*args, **kwargs)
|
||||||
|
if iswindows:
|
||||||
|
# For some reason line buffering does not work on windows
|
||||||
|
end = kwargs.get('end', b'\n')
|
||||||
|
if b'\n' in end:
|
||||||
|
self.flush()
|
||||||
self.rollover()
|
self.rollover()
|
||||||
|
|
||||||
def rename(self, src, dest):
|
def rename(self, src, dest):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user