singer-python icon indicating copy to clipboard operation
singer-python copied to clipboard

`log_debug` cannot work...for very long

Open AlexanderMann opened this issue 5 years ago • 3 comments

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

AlexanderMann avatar Nov 11 '19 17:11 AlexanderMann

@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.

briansloane avatar Nov 12 '19 15:11 briansloane

@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?

AlexanderMann avatar Mar 26 '20 14:03 AlexanderMann

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.

laurentS avatar Jun 02 '22 12:06 laurentS