From 68b64b58ee84fa8e185fa86f58f5aeda28017d4a Mon Sep 17 00:00:00 2001 From: Justin Riley Date: Tue, 2 Aug 2016 17:25:38 -0400 Subject: [PATCH] logger: leave default log completely unconfigured ...dont add NullHandler --- onedns/logger.py | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/onedns/logger.py b/onedns/logger.py index 51a49c3..863967c 100644 --- a/onedns/logger.py +++ b/onedns/logger.py @@ -6,19 +6,7 @@ import logging.handlers LOG_FORMAT = ("%(asctime)s %(filename)s:%(lineno)d - %(levelname)s - " "%(message)s") - -class NullHandler(logging.Handler): - def emit(self, record): - pass - - -def get_onedns_logger(): - log = logging.getLogger('onedns') - log.addHandler(NullHandler()) - return log - - -log = get_onedns_logger() +log = logging.getLogger('onedns') console = logging.StreamHandler() formatter = logging.Formatter(LOG_FORMAT) console.setFormatter(formatter) @@ -29,11 +17,10 @@ def configure_onedns_logging(use_syslog=False, syslog_device='/dev/log', """ Configure logging for onedns *application* code - By default onedns's logger has no formatters and a NullHandler so that - other developers using onedns as a library can configure logging as - they see fit. This method is used in onedns's application code (i.e. - the 'onedns' command) to toggle onedns's application specific - formatters/handlers + By default onedns's logger is completely unconfigured so that other + developers using onedns as a library can configure logging as they see fit. + This method is used in onedns's application code (i.e. the 'onedns' + command) to toggle onedns's application specific formatters/handlers use_syslog - enable logging all messages to syslog. currently only works if /dev/log exists on the system (standard for most Linux distros)