As an ETL Helper user I want a simple way to turn on logging that doesn't add a handler to the ETL Helper logger by default so that I don't get multiple messages.
However, adding a logger to a library is considered bad practice. It would be better if we didn't do this by default. But it would still be useful to be able to easily configure this logger, especially for novice Python users. A function to add the handler would solve this problem. e.g.
def log_to_stderr(level=logging.INFO):
"""Log ETL Helper messages to stderr at level."""
logger = logging.getLogger("etlhelper")
# Add handler
...
# Set level
logger.setLevel(level)
Users would then just add the following to the top of their scripts:
import etlhelper
etlhelper.log_to_stderr()
Acceptance criteria
[x] etlhelper logger has no handler by default
[x] log_to_stderr() adds the current handler and sets logger to given level
Summary
As an ETL Helper user I want a simple way to turn on logging that doesn't add a handler to the ETL Helper logger by default so that I don't get multiple messages.
Description
The current ETL Helper logging setup is configured here: https://github.com/BritishGeologicalSurvey/etlhelper/blob/6cd64fd0dfbf5a40d80437992fae8b69fcbbe05e/etlhelper/__init__.py#L33
The configuration adds a logger with a custom handler that handles DEBUG messages in custom way so that SQL queries and other details that they include are easy to read. By default it is set to WARNING so that it doesn't emit many messages. Logging can be turned on by taking a reference to the logger and setting the level to INFO or below. See: https://github.com/BritishGeologicalSurvey/etlhelper/blob/6cd64fd0dfbf5a40d80437992fae8b69fcbbe05e/README.md?plain=1#L567
However, adding a logger to a library is considered bad practice. It would be better if we didn't do this by default. But it would still be useful to be able to easily configure this logger, especially for novice Python users. A function to add the handler would solve this problem. e.g.
Users would then just add the following to the top of their scripts:
Acceptance criteria
etlhelper
logger has no handler by defaultlog_to_stderr()
adds the current handler and sets logger to given level