[Python-ideas] Logging Levels

Guido van Rossum guido at python.org
Tue Nov 28 14:45:00 EST 2017


These look like good improvements. I think you should make an issue on
bugs.python.org describing your proposal and if you can submit a PR that
implements it.

On Tue, Nov 28, 2017 at 11:25 AM, Mike Miller <python-ideas at mgmiller.net>
wrote:

> Hi,
>
> I use the logging module extensively for even the simplest scripts, one of
> the reasons there's been less difficulty moving to Python 3 at work.  One
> of the "nano features" I've often added to its config is the addition of a
> custom log level.  Never mentioned it before because of its triviality and
> minor use cases, but just realized that I've been doing it five years now
> and happy with it, so why not?
>
> NOTE (~35)
>
> It is called the "note" level and used when one needs to express something
> important, yet positive, and have it be output by default.  The standard
> levels don't support this currently, you often have to potentially scare
> the end user with a warning or higher to have a message emitted.
>
> Typically I use it to return important information that was asked for
> specifically and retrieved successfully, e.g.:
>
>     log.note('Your token is: %s', token)
>     log.note(f'⏵ {item.id} {item.name}')
>
> There are other examples.  Sphinx, has the concept of note admonitions for
> docs in addition to warning and danger.  Bootstrap has note banners for
> web/apps. There is something important to express or highlight, but nothing
> to worry about.
>
>
> FATAL (alias of CRITICAL)
>
> Can't find it now, but believe the docs in the past stated that CRITICAL
> was meant for *unrecoverable* errors.  I've never had a project where I
> didn't shut down immediately after such an occurrence.   Therefore I find
> "FATAL" a more accurate description of what happened.  Log4j and other
> industry loggers use this level name as well.
>
> There is also an aesthetic reason to prefer "fatal".  It is shorter and so
> aligns better with other level names for readability, e.g.:
>
>     console_format = '  %(levelname)-7.7s %(message)s'
>
> Tried but never found a good abbreviation for critical, unfortunately.
> The other option is to add length to align the field.  Most messages use
> the shorter level names (debug, info) so extra length results in wasted
> space that is very rarely needed.
>
> Hopefully someone else finds these useful.  Neither depends on the other.
>
> -Mike
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>



-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20171128/4d9c3a64/attachment-0001.html>


More information about the Python-ideas mailing list