mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-02 17:29:22 +01:00
Moved the disable method closer to its call site.
This commit is contained in:
parent
4dcc4dea87
commit
6d45897278
18
src/log.py
18
src/log.py
@ -90,15 +90,6 @@ class Logger(logging.Logger):
|
|||||||
|
|
||||||
|
|
||||||
class StdoutStreamHandler(logging.StreamHandler):
|
class StdoutStreamHandler(logging.StreamHandler):
|
||||||
def disable(self):
|
|
||||||
self.setLevel(sys.maxint) # Just in case.
|
|
||||||
_logger.removeHandler(self)
|
|
||||||
logging._acquireLock()
|
|
||||||
try:
|
|
||||||
del logging._handlers[self]
|
|
||||||
finally:
|
|
||||||
logging._releaseLock()
|
|
||||||
|
|
||||||
def format(self, record):
|
def format(self, record):
|
||||||
s = logging.StreamHandler.format(self, record)
|
s = logging.StreamHandler.format(self, record)
|
||||||
if record.levelname != 'ERROR' and conf.supybot.log.stdout.wrap():
|
if record.levelname != 'ERROR' and conf.supybot.log.stdout.wrap():
|
||||||
@ -122,6 +113,15 @@ class StdoutStreamHandler(logging.StreamHandler):
|
|||||||
error('Error logging to stdout. Removing stdout handler.')
|
error('Error logging to stdout. Removing stdout handler.')
|
||||||
exception('Uncaught exception in StdoutStreamHandler:')
|
exception('Uncaught exception in StdoutStreamHandler:')
|
||||||
|
|
||||||
|
def disable(self):
|
||||||
|
self.setLevel(sys.maxint) # Just in case.
|
||||||
|
_logger.removeHandler(self)
|
||||||
|
logging._acquireLock()
|
||||||
|
try:
|
||||||
|
del logging._handlers[self]
|
||||||
|
finally:
|
||||||
|
logging._releaseLock()
|
||||||
|
|
||||||
|
|
||||||
class BetterFileHandler(logging.FileHandler):
|
class BetterFileHandler(logging.FileHandler):
|
||||||
def emit(self, record):
|
def emit(self, record):
|
||||||
|
Loading…
Reference in New Issue
Block a user