mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
logging module docs
This commit is contained in:
parent
029e9908c0
commit
6ae8f6ba18
@ -5,11 +5,11 @@ Logging API
|
||||
|
||||
.. function:: sphinx.util.logging.getLogger(name)
|
||||
|
||||
Return a logger wrapped by :class:`SphinxLoggerAdapter` with the specified *name*.
|
||||
Returns a logger wrapped by :class:`SphinxLoggerAdapter` with the specified *name*.
|
||||
|
||||
Example usage::
|
||||
|
||||
from sphinx.util import logging # Load instead python's logging module
|
||||
from sphinx.util import logging # Load on top of python's logging module
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.info('Hello, this is an extension!')
|
||||
@ -20,18 +20,18 @@ Logging API
|
||||
.. method:: SphinxLoggerAdapter.critical(level, msg, *args, **kwargs)
|
||||
.. method:: SphinxLoggerAdapter.warning(level, msg, *args, **kwargs)
|
||||
|
||||
Logs a message with specified level on this logger.
|
||||
Basically, the arguments are same as python's logging module.
|
||||
Logs a message on this logger with the specified level.
|
||||
Basically, the arguments are as with python's logging module.
|
||||
|
||||
In addition, Sphinx logger supports following keyword arguments:
|
||||
|
||||
**type**, ***subtype***
|
||||
Indicate categories of warning logs. It is used to suppress
|
||||
Categories of warning logs. It is used to suppress
|
||||
warnings by :confval:`suppress_warnings` setting.
|
||||
|
||||
**location**
|
||||
Indicate where the warning is happened. It is used to show
|
||||
the path and line number to each log. It allows docname,
|
||||
Where the warning happened. It is used to include
|
||||
the path and line number in each log. It allows docname,
|
||||
tuple of docname and line number and nodes::
|
||||
|
||||
logger = sphinx.util.logging.getLogger(__name__)
|
||||
@ -40,7 +40,7 @@ Logging API
|
||||
logger.warning('Warning happened!', location=some_node)
|
||||
|
||||
**color**
|
||||
Indicate the color of logs. By default, warning level logs are
|
||||
The color of logs. By default, warning level logs are
|
||||
colored as ``"darkred"``. The others are not colored.
|
||||
|
||||
.. method:: SphinxLoggerAdapter.log(level, msg, *args, **kwargs)
|
||||
@ -48,23 +48,23 @@ Logging API
|
||||
.. method:: SphinxLoggerAdapter.verbose(level, msg, *args, **kwargs)
|
||||
.. method:: SphinxLoggerAdapter.debug(level, msg, *args, **kwargs)
|
||||
|
||||
Logs a message with specified level on this logger.
|
||||
Basically, the arguments are same as python's logging module.
|
||||
Logs a message to this logger with the specified level.
|
||||
Basically, the arguments are as with python's logging module.
|
||||
|
||||
In addition, Sphinx logger supports following keyword arguments:
|
||||
|
||||
**nonl**
|
||||
If true, the logger does not fold lines at end of the log message.
|
||||
If true, the logger does not fold lines at the end of the log message.
|
||||
The default is ``False``.
|
||||
|
||||
**color**
|
||||
Indicate the color of logs. By default, debug level logs are
|
||||
colored as ``"darkgray"``, and debug2 ones are ``"lightgray"``.
|
||||
The color of logs. By default, debug level logs are
|
||||
colored as ``"darkgray"``, and debug2 level ones are ``"lightgray"``.
|
||||
The others are not colored.
|
||||
|
||||
.. function:: pending_logging()
|
||||
|
||||
Make all logs as pending while the context::
|
||||
Marks all logs as pending::
|
||||
|
||||
with pending_logging():
|
||||
logger.warning('Warning message!') # not flushed yet
|
||||
@ -74,4 +74,4 @@ Logging API
|
||||
|
||||
.. function:: pending_warnings()
|
||||
|
||||
Make warning logs as pending while the context. Similar to :func:`pending_logging`.
|
||||
Marks warning logs as pending. Similar to :func:`pending_logging`.
|
||||
|
Loading…
Reference in New Issue
Block a user