私は、これは正しい動作だと思う:
logger.debug(「デバッグ」) - >これは任意のフラッシュを待たずに、あなたのファイル「デバッグ」に出力します。
申し訳ありません。はいデフォルトはTrueです。私は上記の追加を見て、私の意見では、動作が正常であるという意味で、終了しないとすべてが実行終了時にフラッシュされる(これは間違ったものをデバッグするために典型的なことです)。終了する場合、メッセージはバッファに追加され、 "False"はメッセージをバッファ内で破棄させます。それは正しい行動ではありませんか?
またflushOnCloseは、以下のようにハンドラクラスに存在しません:
class MemoryHandler(BufferingHandler):
"""
A handler class which buffers logging records in memory, periodically
flushing them to a target handler. Flushing occurs whenever the buffer
is full, or when an event of a certain severity or greater is seen.
"""
def __init__(self, capacity, flushLevel=logging.ERROR, target=None):
"""
Initialize the handler with the buffer size, the level at which
flushing should occur and an optional target.
Note that without a target being set either here or via setTarget(),
a MemoryHandler is no use to anyone!
"""
BufferingHandler.__init__(self, capacity)
self.flushLevel = flushLevel
self.target = target
def shouldFlush(self, record):
"""
Check for buffer full or a record at the flushLevel or higher.
"""
return (len(self.buffer) >= self.capacity) or \
(record.levelno >= self.flushLevel)
def setTarget(self, target):
"""
Set the target handler for this handler.
"""
self.target = target
def flush(self):
"""
For a MemoryHandler, flushing means just sending the buffered
records to the target, if there is one. Override if you want
different behaviour.
The record buffer is also cleared by this operation.
"""
self.acquire()
try:
if self.target:
for record in self.buffer:
self.target.handle(record)
self.buffer = []
finally:
self.release()
def close(self):
"""
Flush, set the target to None and lose the buffer.
"""
try:
self.flush()
finally:
self.acquire()
try:
self.target = None
BufferingHandler.close(self)
finally:
self.release()
とにかく行動はあなたがファイルを開いた場合でも、あなたは、今日が近い場合かを決めることができるという意味で、正常です終わり。最終的には、情報を失わないようにファイルが閉じられます:-)
とにかく、ファイルを開いても最後に近いかどうかを判断することができます。 Pythonは情報を失わないためにファイルを閉じます:-)同様の動作...バッファに書き込んで無視すると、もちろん何も書き込まれません。 –