mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 14:59:34 +01:00
Updated slightly, let's see if this helps.
This commit is contained in:
parent
9c4b80c653
commit
65c9ebc746
16
src/log.py
16
src/log.py
@ -71,20 +71,8 @@ class Logger(logging.Logger):
|
|||||||
self.error('Exception id: %s', eId)
|
self.error('Exception id: %s', eId)
|
||||||
self.error('Exception string: %s', eStrId)
|
self.error('Exception string: %s', eStrId)
|
||||||
|
|
||||||
class BetterStreamHandler(logging.StreamHandler):
|
|
||||||
def emit(self, record):
|
|
||||||
msg = self.format(record)
|
|
||||||
if not hasattr(types, "UnicodeType"): #if no unicode support...
|
|
||||||
self.stream.write("%s%s" % (msg, os.linesep))
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
self.stream.write("%s%s" % (msg, os.linesep))
|
|
||||||
except UnicodeError:
|
|
||||||
self.stream.write("%s%s" % (msg.encode("UTF-8"), os.linesep))
|
|
||||||
self.flush()
|
|
||||||
|
|
||||||
|
class StdoutStreamHandler(logging.StreamHandler):
|
||||||
class StdoutStreamHandler(BetterStreamHandler):
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
self.setLevel(sys.maxint) # Just in case.
|
self.setLevel(sys.maxint) # Just in case.
|
||||||
_logger.removeHandler(self)
|
_logger.removeHandler(self)
|
||||||
@ -97,7 +85,7 @@ class StdoutStreamHandler(BetterStreamHandler):
|
|||||||
def emit(self, record):
|
def emit(self, record):
|
||||||
if conf.supybot.log.stdout() and not conf.daemonized:
|
if conf.supybot.log.stdout() and not conf.daemonized:
|
||||||
try:
|
try:
|
||||||
BetterStreamHandler.emit(self, record)
|
logging.StreamHandler.emit(self, record)
|
||||||
except ValueError, e: # Raised if sys.stdout is closed.
|
except ValueError, e: # Raised if sys.stdout is closed.
|
||||||
self.disable()
|
self.disable()
|
||||||
error('Error logging to stdout. Removing stdout handler.')
|
error('Error logging to stdout. Removing stdout handler.')
|
||||||
|
Loading…
Reference in New Issue
Block a user