mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
py3: port logging.py
This commit is contained in:
parent
b972584f4b
commit
cf0ae84e80
@ -1,4 +1,4 @@
|
|||||||
from __future__ import with_statement
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
@ -15,7 +15,7 @@ from functools import partial
|
|||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
|
||||||
from calibre import isbytestring, force_unicode, as_unicode, prints
|
from calibre import isbytestring, force_unicode, as_unicode, prints
|
||||||
from polyglot.builtins import unicode_type
|
from polyglot.builtins import unicode_type, iteritems
|
||||||
|
|
||||||
|
|
||||||
class Stream(object):
|
class Stream(object):
|
||||||
@ -38,11 +38,11 @@ class ANSIStream(Stream):
|
|||||||
def __init__(self, stream=sys.stdout):
|
def __init__(self, stream=sys.stdout):
|
||||||
Stream.__init__(self, stream)
|
Stream.__init__(self, stream)
|
||||||
self.color = {
|
self.color = {
|
||||||
DEBUG: u'green',
|
DEBUG: u'green',
|
||||||
INFO: None,
|
INFO: None,
|
||||||
WARN: u'yellow',
|
WARN: u'yellow',
|
||||||
ERROR: u'red',
|
ERROR: u'red',
|
||||||
}
|
}
|
||||||
|
|
||||||
def prints(self, level, *args, **kwargs):
|
def prints(self, level, *args, **kwargs):
|
||||||
from calibre.utils.terminal import ColoredStream
|
from calibre.utils.terminal import ColoredStream
|
||||||
@ -65,12 +65,12 @@ class FileStream(Stream):
|
|||||||
class HTMLStream(Stream):
|
class HTMLStream(Stream):
|
||||||
|
|
||||||
color = {
|
color = {
|
||||||
DEBUG: '<span style="color:green">',
|
DEBUG: b'<span style="color:green">',
|
||||||
INFO:'<span>',
|
INFO: b'<span>',
|
||||||
WARN: '<span style="color:blue">',
|
WARN: b'<span style="color:blue">',
|
||||||
ERROR: '<span style="color:red">'
|
ERROR: b'<span style="color:red">'
|
||||||
}
|
}
|
||||||
normal = '</span>'
|
normal = b'</span>'
|
||||||
|
|
||||||
def __init__(self, stream=sys.stdout):
|
def __init__(self, stream=sys.stdout):
|
||||||
Stream.__init__(self, stream)
|
Stream.__init__(self, stream)
|
||||||
@ -87,6 +87,9 @@ class HTMLStream(Stream):
|
|||||||
|
|
||||||
class UnicodeHTMLStream(HTMLStream):
|
class UnicodeHTMLStream(HTMLStream):
|
||||||
|
|
||||||
|
color = {k: v.decode('ascii') for k, v in iteritems(HTMLStream.color)}
|
||||||
|
normal = HTMLStream.normal.decode('ascii')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user