diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-09-21 11:31:32 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2010-09-21 11:31:32 (GMT) |
commit | 212b590e118e3650b596917021ed9612a918180b (patch) | |
tree | 5befc695b2b9b2dd818b74123ed4317efef55a64 /Lib/logging | |
parent | c84f01698874902863396e82a248f5fd6ec59d0e (diff) | |
download | cpython-212b590e118e3650b596917021ed9612a918180b.zip cpython-212b590e118e3650b596917021ed9612a918180b.tar.gz cpython-212b590e118e3650b596917021ed9612a918180b.tar.bz2 |
logging: Updated LoggerAdapter implementation.
Diffstat (limited to 'Lib/logging')
-rw-r--r-- | Lib/logging/__init__.py | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index b7086d5..4c3dd15 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -1376,64 +1376,64 @@ class LoggerAdapter(object): kwargs["extra"] = self.extra return msg, kwargs + # + # Boilerplate convenience methods + # def debug(self, msg, *args, **kwargs): """ - Delegate a debug call to the underlying logger, after adding - contextual information from this adapter instance. + Delegate a debug call to the underlying logger. """ - msg, kwargs = self.process(msg, kwargs) - self.logger.debug(msg, *args, **kwargs) + self.log(DEBUG, msg, *args, **kwargs) def info(self, msg, *args, **kwargs): """ - Delegate an info call to the underlying logger, after adding - contextual information from this adapter instance. + Delegate an info call to the underlying logger. """ - msg, kwargs = self.process(msg, kwargs) - self.logger.info(msg, *args, **kwargs) + self.log(INFO, msg, *args, **kwargs) def warning(self, msg, *args, **kwargs): """ - Delegate a warning call to the underlying logger, after adding - contextual information from this adapter instance. + Delegate a warning call to the underlying logger. """ - msg, kwargs = self.process(msg, kwargs) - self.logger.warning(msg, *args, **kwargs) + self.log(WARNING, msg, *args, **kwargs) warn = warning def error(self, msg, *args, **kwargs): """ - Delegate an error call to the underlying logger, after adding - contextual information from this adapter instance. + Delegate an error call to the underlying logger. """ - msg, kwargs = self.process(msg, kwargs) - self.logger.error(msg, *args, **kwargs) + self.log(ERROR, msg, *args, **kwargs) def exception(self, msg, *args, **kwargs): """ - Delegate an exception call to the underlying logger, after adding - contextual information from this adapter instance. + Delegate an exception call to the underlying logger. """ - msg, kwargs = self.process(msg, kwargs) kwargs["exc_info"] = 1 - self.logger.error(msg, *args, **kwargs) + self.log(ERROR, msg, *args, **kwargs) def critical(self, msg, *args, **kwargs): """ - Delegate a critical call to the underlying logger, after adding - contextual information from this adapter instance. + Delegate a critical call to the underlying logger. """ - msg, kwargs = self.process(msg, kwargs) - self.logger.critical(msg, *args, **kwargs) + self.log(CRITICAL, msg, *args, **kwargs) def log(self, level, msg, *args, **kwargs): """ Delegate a log call to the underlying logger, after adding contextual information from this adapter instance. """ - msg, kwargs = self.process(msg, kwargs) - self.logger.log(level, msg, *args, **kwargs) + if self.isEnabledFor(level): + msg, kwargs = self.process(msg, kwargs) + self.logger._log(level, msg, args, **kwargs) + + def isEnabledFor(self, level): + """ + Is this logger enabled for level 'level'? + """ + if self.logger.manager.disable >= level: + return False + return level >= self.getEffectiveLevel() def setLevel(self, level): """ |