singer-io / singer-python

Writes the Singer format from Python
https://singer.io
Apache License 2.0
537 stars 129 forks source link

`log_debug` cannot work...for very long #113

Open AlexanderMann opened 4 years ago

AlexanderMann commented 4 years ago

Problem

Singer-Python is the root repo for pretty much every tap and target, and the suggested way to log "out" is to use singer.get_logger() or one of the helpers of log_info, or...log_debug.

For target-postgres we use the DEBUG level for logging in tests, and for gaining more information for issues/bug reports etc.

To enable DEBUG logging, we have a single call out to singer.get_logger() followed up by setLevel('DEBUG') (loosely). This works pretty well up until get_logger() gets called again.

Once get_logger gets called again, the fileConfig code gets run again, and the root logger gets reset to the logging.conf and having the level set to INFO.

logging.config.fileConfig(path, disable_existing_loggers=False)

Once this happens, log_debug no longer works.

Question

Is there a suggested way to use/get DEBUG output while also leveraging singer-python?

...or...

Is this a 🐛?

Suggested Musical Pairing

https://soundcloud.com/winnetka-bowling-league/slow-dances

briansloane commented 4 years ago

@AlexanderMann Thanks for raising this. I've chatted with the team and we do think this is unexpected behavior and could be a bug. The team would welcome a PR if the is something you want to take a crack at resolving.

AlexanderMann commented 4 years ago

@briansloane just realized I never pushed anything on this/etc. Do you know if there's been any work on this or if this would still be a welcomed pr?

laurentS commented 2 years ago

Considering how many other repos use this package, I'd not dare to introduce a breaking change here, but would you be open to a PR that allows overriding the log level here via some env var that's unlikely to be used elsewhere, say SINGER_LOGLEVEL for instance. If not set, nothing changes, but it allows users to opt-in to a cleaner behaviour.