# HG changeset patch # User jruigrok # Date 1298385022 0 # Node ID 4eaad9bf0e5a11fced94a3c93d96924d2bf835f8 # Parent 96a7c4a5990c8642f9658230dfaac774783fca16 Prevent multiple handlers being attached to the same logger. Issue: #227 Submitted by: dfraser diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,7 @@ * 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 --- a/babel/messages/frontend.py +++ b/babel/messages/frontend.py @@ -629,11 +629,14 @@ # 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()