From f42d95ebd167b4a0b0edfdfc6f15bd8c5cec799b Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Sat, 21 Feb 2004 22:14:34 +0000 Subject: [PATCH] Added close() (which flushes) to BufferingHandler and tidied MemoryHandler.close() [SF #901330] --- Lib/logging/handlers.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index c556f1a0ff..778c5074b0 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -1,4 +1,4 @@ -# Copyright 2001-2002 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2004 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -726,6 +726,15 @@ class BufferingHandler(logging.Handler): """ self.buffer = [] + def close(self): + """ + Close the handler. + + This version just flushes and chains to the parent class' close(). + """ + self.flush() + logging.Handler.close(self) + class MemoryHandler(BufferingHandler): """ A handler class which buffers logging records in memory, periodically @@ -774,5 +783,4 @@ class MemoryHandler(BufferingHandler): """ self.flush() self.target = None - self.buffer = [] BufferingHandler.close(self) -- 2.50.1