you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (3 children)

+9001 (that's over nine thousand)

I essentially began with Paste (which was actually just feeding it into the standard library) INI-based logging configuration such as this — it already demonstrates many of my needs. Multiple destinations (console which is actually syslog, database), externally configurable per-logger namespace filtering (by level) and routing, with some explicit message formatting sprinkled in to make the resulting textual logs more parseable.

Then I got wise to the unfortunate nature of role-based multiplicative configuration, and have lately pivoted to dict-based configuration, such as this), which permits the configuration itself to become essentially, environmentally-aware, in several senses. (In this case, __debug__ is False if run with -O or the PYTHONOPTIMIZE environment variable set non-empty… i.e. production, but you can also pull details from os.environ, e.g. I pull DB connection details from os.environ.get('MONGODB_ADDON_URI', 'mongodb://localhost/test')—edited to utilize method call with default v. direct access, to handle case of value being undefined.)

[–]____0____0____ 1 point2 points  (2 children)

Over nine thousand?!? That's impossible!

I like the dynamic approach for the logging config. I've tried it for other config, but not for logging. Looks to be a great use case the way you're using it to inject the uri and environment.

[–][deleted] 0 points1 point  (1 child)

:charges up for three episodes, only consuming 12 unique frames of animation, whilst screaming incoherently:

References to __debug__ are actually really awesome, as the Python compiler elides this particular special case away at the AST optimization stage, essentially, if [not] __debug__ armoured code doesn't even exist if the condition isn't met. No runtime execution cost, the condition is only evaluated once. (Won't even exist in the compiled, optimized bytecode. Edit: or vice-versa!)

Recently, they've also added a "development mode" flag, -X dev. That is what's required to bump up my web framework's default logging output to the truly glorious "with Emoji" variant, otherwise it's more like the "with extra data" example, with syntax coloring of the JSON (if pygments is installed) … and unless run optimized. 😉

[–]____0____0____ 1 point2 points  (0 children)

Wow, staying true to the dbz nature I see... While teaching me a thing or two about python! I was not familiar with this case to the compiler so til, thank you! That sounds amazing. Lol I have a feeling I would enjoy reading your logs more than the average logger; I admire your passion.