diff --git a/singer/logger.py b/singer/logger.py index 2113f22..a77ae33 100644 --- a/singer/logger.py +++ b/singer/logger.py @@ -3,10 +3,17 @@ import os -def get_logger(): - """Return a Logger instance appropriate for using in a Tap or a Target.""" +_INIT_LOGGER = True + + +def init_logger(): + """Initialize the Logger instance.""" + # pylint: disable=W0603 + global _INIT_LOGGER + this_dir, _ = os.path.split(__file__) - path = os.path.join(this_dir, 'logging.conf') + path = os.path.join(this_dir, "logging.conf") + # See # https://docs.python.org/3.5/library/logging.config.html#logging.config.fileConfig # for a discussion of why or why not to set disable_existing_loggers @@ -14,6 +21,16 @@ def get_logger(): # False it ruins external module's abilities to use the logging # facility. logging.config.fileConfig(path, disable_existing_loggers=False) + + # Only initialize the logger once. + _INIT_LOGGER = False + + +def get_logger(): + """Return a Logger instance appropriate for using in a Tap or a Target.""" + if _INIT_LOGGER: + init_logger() + return logging.getLogger()