2016-12-28 06:14:56 -06:00
|
|
|
.. _logging-api:
|
|
|
|
|
|
|
|
Logging API
|
|
|
|
===========
|
|
|
|
|
2017-12-04 14:30:48 -06:00
|
|
|
.. currentmodule:: sphinx.util.logging
|
2016-12-28 06:14:56 -06:00
|
|
|
|
2017-12-04 14:30:48 -06:00
|
|
|
.. autofunction:: getLogger(name)
|
2016-12-28 06:14:56 -06:00
|
|
|
|
2017-12-04 14:30:48 -06:00
|
|
|
.. autoclass:: SphinxLoggerAdapter(logging.LoggerAdapter)
|
2016-12-28 06:14:56 -06:00
|
|
|
|
2018-08-24 11:47:34 -05:00
|
|
|
.. method:: SphinxLoggerAdapter.error(msg, *args, **kwargs)
|
|
|
|
.. method:: SphinxLoggerAdapter.critical(msg, *args, **kwargs)
|
|
|
|
.. method:: SphinxLoggerAdapter.warning(msg, *args, **kwargs)
|
2016-12-28 06:14:56 -06:00
|
|
|
|
2017-02-07 13:03:07 -06:00
|
|
|
Logs a message on this logger with the specified level.
|
|
|
|
Basically, the arguments are as with python's logging module.
|
2016-12-28 06:14:56 -06:00
|
|
|
|
|
|
|
In addition, Sphinx logger supports following keyword arguments:
|
|
|
|
|
|
|
|
**type**, ***subtype***
|
2017-02-07 13:03:07 -06:00
|
|
|
Categories of warning logs. It is used to suppress
|
2016-12-28 06:14:56 -06:00
|
|
|
warnings by :confval:`suppress_warnings` setting.
|
|
|
|
|
|
|
|
**location**
|
2017-02-07 13:03:07 -06:00
|
|
|
Where the warning happened. It is used to include
|
|
|
|
the path and line number in each log. It allows docname,
|
2016-12-28 06:14:56 -06:00
|
|
|
tuple of docname and line number and nodes::
|
|
|
|
|
|
|
|
logger = sphinx.util.logging.getLogger(__name__)
|
|
|
|
logger.warning('Warning happened!', location='index')
|
|
|
|
logger.warning('Warning happened!', location=('chapter1/index', 10))
|
|
|
|
logger.warning('Warning happened!', location=some_node)
|
|
|
|
|
|
|
|
**color**
|
2018-08-24 11:47:34 -05:00
|
|
|
The color of logs. By default, error level logs are colored as
|
|
|
|
``"darkred"``, critical level ones is not colored, and warning level
|
|
|
|
ones are colored as ``"red"``.
|
2016-12-28 06:14:56 -06:00
|
|
|
|
|
|
|
.. method:: SphinxLoggerAdapter.log(level, msg, *args, **kwargs)
|
2018-08-24 11:47:34 -05:00
|
|
|
.. method:: SphinxLoggerAdapter.info(msg, *args, **kwargs)
|
|
|
|
.. method:: SphinxLoggerAdapter.verbose(msg, *args, **kwargs)
|
|
|
|
.. method:: SphinxLoggerAdapter.debug(msg, *args, **kwargs)
|
2016-12-28 06:14:56 -06:00
|
|
|
|
2017-02-07 13:03:07 -06:00
|
|
|
Logs a message to this logger with the specified level.
|
|
|
|
Basically, the arguments are as with python's logging module.
|
2016-12-28 06:14:56 -06:00
|
|
|
|
|
|
|
In addition, Sphinx logger supports following keyword arguments:
|
|
|
|
|
|
|
|
**nonl**
|
2017-02-07 13:03:07 -06:00
|
|
|
If true, the logger does not fold lines at the end of the log message.
|
2016-12-28 06:14:56 -06:00
|
|
|
The default is ``False``.
|
|
|
|
|
2018-06-23 00:41:01 -05:00
|
|
|
**location**
|
|
|
|
Where the message emitted. For more detail, see
|
|
|
|
:meth:`SphinxLoggerAdapter.warning`.
|
|
|
|
|
2016-12-28 06:14:56 -06:00
|
|
|
**color**
|
2018-08-24 11:47:34 -05:00
|
|
|
The color of logs. By default, info and verbose level logs are not colored,
|
|
|
|
and deug level ones are colored as ``"darkgray"``.
|
2016-12-28 06:14:56 -06:00
|
|
|
|
2017-12-04 14:30:48 -06:00
|
|
|
.. autofunction:: pending_logging()
|
2016-12-28 06:14:56 -06:00
|
|
|
|
2017-12-04 14:30:48 -06:00
|
|
|
.. autofunction:: pending_warnings()
|