mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-26 03:54:08 +01:00
log: Add support for rotating messages.log.
This commit is contained in:
parent
666acd9f1f
commit
dff394df64
@ -34,6 +34,7 @@ import time
|
|||||||
import types
|
import types
|
||||||
import atexit
|
import atexit
|
||||||
import logging
|
import logging
|
||||||
|
import logging.handlers
|
||||||
import operator
|
import operator
|
||||||
import textwrap
|
import textwrap
|
||||||
import traceback
|
import traceback
|
||||||
@ -125,12 +126,14 @@ class StdoutStreamHandler(logging.StreamHandler):
|
|||||||
logging._releaseLock()
|
logging._releaseLock()
|
||||||
|
|
||||||
|
|
||||||
class BetterFileHandler(logging.FileHandler):
|
class BetterFileHandler(logging.handlers.WatchedFileHandler):
|
||||||
def emit(self, record):
|
def emit(self, record):
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
super().emit(record)
|
super().emit(record)
|
||||||
except (UnicodeError, TypeError):
|
except (UnicodeError, TypeError):
|
||||||
|
# the above line took care of calling reopenIfNeeded(), even
|
||||||
|
# if it raised one of these exceptions.
|
||||||
msg = self.format(record)
|
msg = self.format(record)
|
||||||
self.stream.write(repr(msg))
|
self.stream.write(repr(msg))
|
||||||
self.stream.write(os.linesep)
|
self.stream.write(os.linesep)
|
||||||
|
Loading…
Reference in New Issue
Block a user