Raymond Hettinger added the comment:

> logger.info( f" {logger.name:s} {logger.module:s} " ) 
>
> this could be supported with full backward compatibility 
> with very little effort.   
>
> Am I missing something?

One issue is that some of that data isn't known until the logging.info() call 
is made. And accessing the data before the call would bypass the internal 
locks, potentially causing race conditions.

Another issue is that having to use an attribute lookup for every variable 
isn't fast and doesn't look very nice (making this feature awkward to use when 
the whole goal is to improve usability).

FWIW, you can already use f-strings for all of your local data.  The logging 
internal data tends to be already set upsteam in the configuration format 
(which is only done once):

    # Formatting is only done once so %-formatting isn't problematic
    logging.basicConfig(
        level = logging.INFO,
        format = '%(levelname)-8s | %(asctime)s | %(message)s',
        filename = 'demo.log',
    )

    # In the body of the code, use f-strings for your local data:
    logging.info(f'There are {active_users} in {session_name}')

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue30995>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to