from Hacker News

Show HN: Logging2, An Improved Python Logging Utility

by vforgione on 5/1/17, 7:53 PM with 1 comments

  • by vforgione on 5/1/17, 7:53 PM

    About a year ago I got really fed up with the way the logging library in python works. I was trying to inject request ids (Flask app with a custom before_request hook to create the ids) into every log entry and ran into numerous issues - should it be an adapter, a filter, should I just wrap the logging methods, how will it handle the dynamic injection of the data?

    Eventually after 4 days of struggling to find the right mixture I settled on a custom adapter and a global instance of a logger and replacing the app logger with it. It was a hack on a hack on a hack. I wan't satisfied. (On top of that, we had machines with different timezones, so trying to align our logs later on was a separate mess given the inflexibility of the timestamp formatting).

    So, I started designing and refining my idea of what a more modern, pythonic logging utility would look like. I've made several iterations on the design and API, and I'm finally ready to let people take it for a test drive.