Closes #27904: Improved logging statements to defer formatting until needed.

This commit is contained in:
Vinay Sajip 2016-08-31 08:22:29 +01:00
parent ee47e5cf8a
commit dd917f84e3
15 changed files with 25 additions and 26 deletions

View file

@ -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::

View file

@ -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)

View file

@ -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