Debian Codegraph @

doc/extdev/logging.rst

raw
1 .. _logging-api:
2
3 Logging API
4 ===========
5
6 .. currentmodule:: sphinx.util.logging
7
8 .. autofunction:: getLogger(name)
9
10 .. autoclass:: SphinxLoggerAdapter(logging.LoggerAdapter)
11
12 .. method:: SphinxLoggerAdapter.error(msg, *args, **kwargs)
13 .. method:: SphinxLoggerAdapter.critical(msg, *args, **kwargs)
14 .. method:: SphinxLoggerAdapter.warning(msg, *args, **kwargs)
15
16 Logs a message on this logger with the specified level.
17 Basically, the arguments are as with python's logging module.
18
19 In addition, Sphinx logger supports following keyword arguments:
20
21 **type**, ***subtype***
22 Categories of warning logs. It is used to suppress
23 warnings by :confval:`suppress_warnings` setting.
24
25 **location**
26 Where the warning happened. It is used to include
27 the path and line number in each log. It allows docname,
28 tuple of docname and line number and nodes::
29
30 logger = sphinx.util.logging.getLogger(__name__)
31 logger.warning('Warning happened!', location='index')
32 logger.warning('Warning happened!', location=('chapter1/index', 10))
33 logger.warning('Warning happened!', location=some_node)
34
35 **color**
36 The color of logs. By default, error level logs are colored as
37 ``"darkred"``, critical level ones is not colored, and warning level
38 ones are colored as ``"red"``.
39
40 .. method:: SphinxLoggerAdapter.log(level, msg, *args, **kwargs)
41 .. method:: SphinxLoggerAdapter.info(msg, *args, **kwargs)
42 .. method:: SphinxLoggerAdapter.verbose(msg, *args, **kwargs)
43 .. method:: SphinxLoggerAdapter.debug(msg, *args, **kwargs)
44
45 Logs a message to this logger with the specified level.
46 Basically, the arguments are as with python's logging module.
47
48 In addition, Sphinx logger supports following keyword arguments:
49
50 **nonl**
51 If true, the logger does not fold lines at the end of the log message.
52 The default is ``False``.
53
54 **location**
55 Where the message emitted. For more detail, see
56 :meth:`SphinxLoggerAdapter.warning`.
57
58 **color**
59 The color of logs. By default, info and verbose level logs are not
60 colored, and debug level ones are colored as ``"darkgray"``.
61
62 .. autofunction:: pending_logging()
63
64 .. autofunction:: pending_warnings()
65
66 .. autofunction:: prefixed_warnings()