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 import prints
|
||||||
from calibre.constants import iswindows
|
from calibre.constants import iswindows
|
||||||
|
from calibre.utils.terminal import polyglot_write
|
||||||
from calibre.srv.errors import HTTPNotFound
|
from calibre.srv.errors import HTTPNotFound
|
||||||
from calibre.utils.localization import get_translator
|
from calibre.utils.localization import get_translator
|
||||||
from calibre.utils.socket_inheritance import set_socket_inherit
|
from calibre.utils.socket_inheritance import set_socket_inherit
|
||||||
@ -327,9 +328,16 @@ class RotatingStream(object):
|
|||||||
def flush(self):
|
def flush(self):
|
||||||
self.stream.flush()
|
self.stream.flush()
|
||||||
|
|
||||||
|
def write(self, x):
|
||||||
|
return polyglot_write(self.stream, True, 'utf-8', x)
|
||||||
|
|
||||||
def prints(self, level, *args, **kwargs):
|
def prints(self, level, *args, **kwargs):
|
||||||
kwargs['file'] = self.stream
|
kwargs['file'] = self
|
||||||
self.current_pos += prints(*args, **kwargs)
|
prints(*args, **kwargs)
|
||||||
|
try:
|
||||||
|
self.current_pos = self.stream.tell()
|
||||||
|
except EnvironmentError:
|
||||||
|
self.current_pos = 0
|
||||||
# line bufferring only works with text mode streams
|
# line bufferring only works with text mode streams
|
||||||
end = kwargs.get('end', b'\n')
|
end = kwargs.get('end', b'\n')
|
||||||
if isinstance(end, unicode_type):
|
if isinstance(end, unicode_type):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user