From: Jeroen Ruigrok van der Werven Date: Tue, 22 Feb 2011 14:30:22 +0000 (+0000) Subject: Prevent multiple handlers being attached to the same logger. X-Git-Tag: 1.0~228 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af6ce8f688a37898024bad6a40c2dcc8528e6077;p=thirdparty%2Fbabel.git Prevent multiple handlers being attached to the same logger. Issue: #227 Submitted by: dfraser --- diff --git a/ChangeLog b/ChangeLog index 8638f1c5..7533ad3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,7 @@ http://svn.edgewall.org/repos/babel/tags/1.0.0/ * Removed ValueError raising for string formatting message checkers if the string does not contain any string formattings (ticket #150). * Fix Serbian plural forms (ticket #213). + * Prevent multiple handlers being added to the same logger (ticket #227). Version 0.9.6 diff --git a/babel/messages/frontend.py b/babel/messages/frontend.py index b1ebfb4a..0aa535d9 100755 --- a/babel/messages/frontend.py +++ b/babel/messages/frontend.py @@ -629,11 +629,14 @@ class CommandLineInterface(object): # Configure logging self.log = logging.getLogger('babel') self.log.setLevel(options.loglevel) - handler = logging.StreamHandler() - handler.setLevel(options.loglevel) + if self.log.handlers: + handler = self.log.handlers[0] + else: + handler = logging.StreamHandler() + self.log.addHandler(handler) formatter = logging.Formatter('%(message)s') handler.setFormatter(formatter) - self.log.addHandler(handler) + handler.setLevel(options.loglevel) if options.list_locales: identifiers = localedata.list()