Writing good, usable logs is not an easy task.
uberlogs does all the dumb work you have to do, to make your logs easy to parse.
- Drop-in replacement for logging - fully backwards compatible with logging.
- Human Readable, parsable log lines (with or without color)
- Machine readable parsable log lines for your favorite data cruncher (json)
- Variable formatting, so you don’t have to write .format(…) or % (…) ever again
- Statement evaluation like in Ruby, Koltin, Python 3.6, etc’
- Handler to violently kill the process when a log on a specific level has been written
- Automatic twisted log rewriting to python.logging
you can find it on github. Feel free to open issues or submit pull requests!
Performance
I was extremely performance aware while writing this library. It does a lot of magic, and most of the time python magic is expensive. I had to use every trick I could come up with (including ahead of time compilation!) to make the performance overhead as low as I can. My work isn’t done, but I reached an acceptable overhead:
$ ITERATIONS=10000 python profile.py 1> /dev/null |
Why did I write uberlogs?
I rarely use any other logging appenders than the console one. Most of the time I send my logs to a data cruncher and write horrible regular expressions to parse the data.
To ease the pain, I started formatting my logs, so they’ll be easy to parse: arg1=arg1val; arg2=arg2val
But that meant I had to write the same format everywhere, and I found myself writing long, long log lines:
import logging |
I had to find a better, more concise way of doing the same - that way is uberlogs:
import uberlogs |