Skip to content

Init logger #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions singer/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,34 @@
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
# to False. The long and short of it is that if you don't set it to
# 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()


Expand Down