From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id B3B50138204 for ; Fri, 6 Sep 2013 17:27:46 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E6F4EE0F9B; Fri, 6 Sep 2013 17:27:45 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 55B54E0F9B for ; Fri, 6 Sep 2013 17:27:45 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 53FA433EBDF for ; Fri, 6 Sep 2013 17:27:44 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 0EAE5E5463 for ; Fri, 6 Sep 2013 17:27:43 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1378488079.d15762c4a6b15b3216c996ca43fba243374a3a9b.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/recipe/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/recipe/easylogger.py X-VCS-Directories: roverlay/recipe/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: d15762c4a6b15b3216c996ca43fba243374a3a9b X-VCS-Branch: master Date: Fri, 6 Sep 2013 17:27:43 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: be47b013-8901-4a30-a736-729484aa2922 X-Archives-Hash: 9026f542645c89d7681c7ca1d22bd213 commit: d15762c4a6b15b3216c996ca43fba243374a3a9b Author: André Erdmann mailerd de> AuthorDate: Fri Sep 6 17:21:19 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Fri Sep 6 17:21:19 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=d15762c4 recipe/easylogger: accept log formatter for "initial" console logging --- roverlay/recipe/easylogger.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/roverlay/recipe/easylogger.py b/roverlay/recipe/easylogger.py index c37f0cd..4ba2b46 100644 --- a/roverlay/recipe/easylogger.py +++ b/roverlay/recipe/easylogger.py @@ -39,9 +39,9 @@ def freeze_status(): force_reset ( 10 ) # --- end of freeze_status (...) --- -def force_console_logging ( log_level=logging.DEBUG ): +def force_console_logging ( log_level=logging.DEBUG, log_formatter=None ): force_reset() - setup_initial ( log_level=log_level ) + setup_initial ( log_level=log_level, log_formatter=log_formatter ) freeze_status() # --- end of force_console_logging (...) --- @@ -50,15 +50,18 @@ def _zap_handlers(): ROOT_LOGGER.removeHandler ( h ) # --- end of _zap_handlers (...) --- -def setup_initial_console ( log_level=logging.WARN ): +def setup_initial_console ( log_level=logging.WARN, log_formatter=None ): ch = logging.StreamHandler ( stream=DEFAULT_STREAM ) ch.setLevel ( log_level ) - ch.setFormatter ( - logging.Formatter ( - fmt='%(levelname)-7s [%(name)s] %(message)s' + if log_formatter is None: + ch.setFormatter ( + logging.Formatter ( + fmt='%(levelname)-7s [%(name)s] %(message)s' + ) ) - ) + else: + ch.setFormatter ( log_formatter ) ROOT_LOGGER.addHandler ( ch ) ROOT_LOGGER.setLevel ( ch.level ) @@ -198,7 +201,7 @@ def setup ( conf ): _STATUS = 2 -def setup_initial ( log_level=None ): +def setup_initial ( log_level=None, log_formatter=None ): global _STATUS if _STATUS > 0: return @@ -207,8 +210,10 @@ def setup_initial ( log_level=None ): logging.lastResort = None logging.raiseExceptions = True if log_level is None: - setup_initial_console() + setup_initial_console ( log_formatter=log_formatter ) else: - setup_initial_console ( log_level=log_level ) + setup_initial_console ( + log_level=log_level, log_formatter=log_formatter + ) _STATUS = 1