mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Closes #27904: Improved logging statements to defer formatting until needed.
This commit is contained in:
parent
ee47e5cf8a
commit
dd917f84e3
15 changed files with 25 additions and 26 deletions
|
|
@ -590,10 +590,10 @@ single definition::
|
|||
self.name = name
|
||||
|
||||
def __enter__(self):
|
||||
logging.info('Entering: {}'.format(self.name))
|
||||
logging.info('Entering: %s', self.name)
|
||||
|
||||
def __exit__(self, exc_type, exc, exc_tb):
|
||||
logging.info('Exiting: {}'.format(self.name))
|
||||
logging.info('Exiting: %s', self.name)
|
||||
|
||||
Instances of this class can be used as both a context manager::
|
||||
|
||||
|
|
|
|||
|
|
@ -425,7 +425,7 @@ Another example that uses the *ignore* argument to add a logging call::
|
|||
import logging
|
||||
|
||||
def _logpath(path, names):
|
||||
logging.info('Working in %s' % path)
|
||||
logging.info('Working in %s', path)
|
||||
return [] # nothing will be ignored
|
||||
|
||||
copytree(source, destination, ignore=_logpath)
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ A user-defined class can be defined as a generic class.
|
|||
return self.value
|
||||
|
||||
def log(self, message: str) -> None:
|
||||
self.logger.info('{}: {}'.format(self.name, message))
|
||||
self.logger.info('%s: %s', self.name, message)
|
||||
|
||||
``Generic[T]`` as a base class defines that the class ``LoggedVar`` takes a
|
||||
single type parameter ``T`` . This also makes ``T`` valid as a type within the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue