.. versionchanged:: 3.8
The *stacklevel* parameter was added.
- .. versionchanged:: 3.13
- Remove the undocumented ``warn()`` method which was an alias to the
- :meth:`warning` method.
-
.. method:: Logger.info(msg, *args, **kwargs)
Logs a message with level :const:`WARNING` on this logger. The arguments are
interpreted as for :meth:`debug`.
+ .. note:: There is an obsolete method ``warn`` which is functionally
+ identical to ``warning``. As ``warn`` is deprecated, please do not use
+ it - use ``warning`` instead.
+
.. method:: Logger.error(msg, *args, **kwargs)
Logs a message with level :const:`ERROR` on this logger. The arguments are
Attribute :attr:`!manager` and method :meth:`!_log` were added, which
delegate to the underlying logger and allow adapters to be nested.
- .. versionchanged:: 3.13
-
- Remove the undocumented :meth:`!warn`` method which was an alias to the
- :meth:`!warning` method.
-
.. versionchanged:: 3.13
The *merge_extra* argument was added.
identical to ``warning``. As ``warn`` is deprecated, please do not use
it - use ``warning`` instead.
- .. versionchanged:: 3.13
- Remove the undocumented ``warn()`` function which was an alias to the
- :func:`warning` function.
-
.. function:: error(msg, *args, **kwargs)
'captureWarnings', 'critical', 'debug', 'disable', 'error',
'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass',
'info', 'log', 'makeLogRecord', 'setLoggerClass', 'shutdown',
- 'warning', 'getLogRecordFactory', 'setLogRecordFactory',
+ 'warn', 'warning', 'getLogRecordFactory', 'setLogRecordFactory',
'lastResort', 'raiseExceptions', 'getLevelNamesMapping',
'getHandlerByName', 'getHandlerNames']
if self.isEnabledFor(WARNING):
self._log(WARNING, msg, args, **kwargs)
+ def warn(self, msg, *args, **kwargs):
+ warnings.warn("The 'warn' method is deprecated, "
+ "use 'warning' instead", DeprecationWarning, 2)
+ self.warning(msg, *args, **kwargs)
+
def error(self, msg, *args, **kwargs):
"""
Log 'msg % args' with severity 'ERROR'.
"""
self.log(WARNING, msg, *args, **kwargs)
+ def warn(self, msg, *args, **kwargs):
+ warnings.warn("The 'warn' method is deprecated, "
+ "use 'warning' instead", DeprecationWarning, 2)
+ self.warning(msg, *args, **kwargs)
+
def error(self, msg, *args, **kwargs):
"""
Delegate an error call to the underlying logger.
basicConfig()
root.warning(msg, *args, **kwargs)
+def warn(msg, *args, **kwargs):
+ warnings.warn("The 'warn' function is deprecated, "
+ "use 'warning' instead", DeprecationWarning, 2)
+ warning(msg, *args, **kwargs)
+
def info(msg, *args, **kwargs):
"""
Log a message with severity 'INFO' on the root logger. If the logger has