diff --git a/setup.py b/setup.py index 919cb1c..8552ce6 100755 --- a/setup.py +++ b/setup.py @@ -28,5 +28,11 @@ 'singer-tools' ] }, - packages=find_packages(), + packages=['singer'], + package_data={ + 'singer': [ + 'logging.conf' + ] + }, + include_package_data=True ) diff --git a/singer/logger.py b/singer/logger.py index 909fdc5..2453eb9 100644 --- a/singer/logger.py +++ b/singer/logger.py @@ -5,8 +5,14 @@ def get_logger(name='singer'): """Return a Logger instance to use in singer.""" + # Use custom logging config provided by environment variable if 'LOGGING_CONF_FILE' in os.environ and os.environ['LOGGING_CONF_FILE']: path = os.environ['LOGGING_CONF_FILE'] logging.config.fileConfig(path, disable_existing_loggers=False) + # Use the default logging conf that meets the singer specs criteria + else: + this_dir, _ = os.path.split(__file__) + path = os.path.join(this_dir, 'logging.conf') + logging.config.fileConfig(path, disable_existing_loggers=False) return logging.getLogger(name) diff --git a/singer/logging.conf b/singer/logging.conf new file mode 100644 index 0000000..b9a0b7a --- /dev/null +++ b/singer/logging.conf @@ -0,0 +1,25 @@ +[loggers] +keys=root + +[handlers] +keys=stderr + +[formatters] +keys=child + +[logger_root] +level=INFO +handlers=stderr +formatter=child +propagate=0 + +[handler_stderr] +level=INFO +class=StreamHandler +formatter=child +args=(sys.stderr,) + +[formatter_child] +class=logging.Formatter +format=time=%(asctime)s name=%(name)s level=%(levelname)s message=%(message)s +datefmt=%Y-%m-%d %H:%M:%S