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'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
@ -15,7 +15,7 @@ from functools import partial
|
||||
from threading import Lock
|
||||
|
||||
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):
|
||||
@ -65,12 +65,12 @@ class FileStream(Stream):
|
||||
class HTMLStream(Stream):
|
||||
|
||||
color = {
|
||||
DEBUG: '<span style="color:green">',
|
||||
INFO:'<span>',
|
||||
WARN: '<span style="color:blue">',
|
||||
ERROR: '<span style="color:red">'
|
||||
DEBUG: b'<span style="color:green">',
|
||||
INFO: b'<span>',
|
||||
WARN: b'<span style="color:blue">',
|
||||
ERROR: b'<span style="color:red">'
|
||||
}
|
||||
normal = '</span>'
|
||||
normal = b'</span>'
|
||||
|
||||
def __init__(self, stream=sys.stdout):
|
||||
Stream.__init__(self, stream)
|
||||
@ -87,6 +87,9 @@ class HTMLStream(Stream):
|
||||
|
||||
class UnicodeHTMLStream(HTMLStream):
|
||||
|
||||
color = {k: v.decode('ascii') for k, v in iteritems(HTMLStream.color)}
|
||||
normal = HTMLStream.normal.decode('ascii')
|
||||
|
||||
def __init__(self):
|
||||
self.clear()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user