mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix logging in the server for py3
This commit is contained in:
parent
f884aa1307
commit
9f57d6ce52
@ -12,6 +12,7 @@ from operator import itemgetter
|
||||
|
||||
from calibre import prints
|
||||
from calibre.constants import iswindows
|
||||
from calibre.utils.terminal import polyglot_write
|
||||
from calibre.srv.errors import HTTPNotFound
|
||||
from calibre.utils.localization import get_translator
|
||||
from calibre.utils.socket_inheritance import set_socket_inherit
|
||||
@ -327,9 +328,16 @@ class RotatingStream(object):
|
||||
def flush(self):
|
||||
self.stream.flush()
|
||||
|
||||
def write(self, x):
|
||||
return polyglot_write(self.stream, True, 'utf-8', x)
|
||||
|
||||
def prints(self, level, *args, **kwargs):
|
||||
kwargs['file'] = self.stream
|
||||
self.current_pos += prints(*args, **kwargs)
|
||||
kwargs['file'] = self
|
||||
prints(*args, **kwargs)
|
||||
try:
|
||||
self.current_pos = self.stream.tell()
|
||||
except EnvironmentError:
|
||||
self.current_pos = 0
|
||||
# line bufferring only works with text mode streams
|
||||
end = kwargs.get('end', b'\n')
|
||||
if isinstance(end, unicode_type):
|
||||
|
Loading…
x
Reference in New Issue
Block a user