• Home
  • Raw
  • Download

Lines Matching full:logging

1 :mod:`logging` --- Logging facility for Python
4 .. module:: logging
5 :synopsis: Flexible event logging system for applications.
10 **Source code:** :source:`Lib/logging/__init__.py`
12 .. index:: pair: Errors; logging
19 * :ref:`Basic Tutorial <logging-basic-tutorial>`
20 * :ref:`Advanced Tutorial <logging-advanced-tutorial>`
21 * :ref:`Logging Cookbook <logging-cookbook>`
26 logging system for applications and libraries.
28 The key benefit of having the logging API provided by a standard library module
29 is that all Python modules can participate in logging, so your application log
34 unfamiliar with logging, the best way to get to grips with it is to see the
55 ``logging.getLogger(name)``. Multiple calls to :func:`getLogger` with the same
66 ``logging.getLogger(__name__)``. That's because in a module, ``__name__``
80 If this evaluates to false, logging messages are not passed to the handlers
85 ``logging.getLogger('A.B.C').error(...)`` will [subject to passing that logger's
105 Sets the threshold for this logger to *level*. Logging messages which are less
106 severe than *level* will be ignored; logging messages which have severity *level*
121 began, and is used to determine how a logging event is handled.
140 ``logging.disable(level)`` and then the logger's effective level as determined
150 an integer, typically one of :const:`logging.DEBUG`, :const:`logging.INFO`
157 Thus, ``logging.getLogger('abc').getChild('def.ghi')`` would return the same
158 logger as would be returned by ``logging.getLogger('abc.def.ghi')``. This is a
177 added to the logging message. If an exception tuple (in the format returned by
182 ``False``. If true, stack information is added to the logging
183 message, including the actual logging call. Note that this is not the same
185 former is stack frames from the bottom of the stack up to the logging call
204 created for the logging event. This can be used in logging helpers so that
211 created for the logging event with user-defined attributes. These custom
216 logging.basicConfig(format=FORMAT)
218 logger = logging.getLogger('tcpserver')
228 by the logging system. (See the :class:`Formatter` documentation for more
229 information on which keys are used by the logging system.)
291 interpreted as for :meth:`debug`. Exception info is added to the logging
333 when calling logging APIs from helper/wrapper code, so that the information
367 Logging Levels
370 The numeric values of logging levels are given in the following table. These are
430 Sets the threshold for this handler to *level*. Logging messages which are
469 Ensure all logging output has been flushed. This version does nothing and is
483 Conditionally emits the specified logging record, depending on filters which may
493 what is mostly wanted for a logging system - most users will not care about
494 errors in the logging system, they are more interested in application
509 Do whatever it takes to actually log the specified logging record. This version
513 For a list of handlers included as standard, see :mod:`logging.handlers`.
520 .. currentmodule:: logging
527 the message in the logging call. To have additional items of information in the
559 ``logging.Formatter('%(ip)s %(message)s', defaults={"ip": None})``
567 For example: ``logging.Formatter('%(asctime)s - %(message)s', style='{')``.
611 want all logging times to be shown in GMT, set the ``converter``
721 :param level: The numeric level of the logging event (one of DEBUG, INFO etc.)
725 :param pathname: The full pathname of the source file where the logging call
727 :param lineno: The line number in the source file where the logging call was
735 :param func: The name of the function or method from which the logging call
738 the stack in the current thread, up to the logging call.
744 argument to the logging call is not a string, :func:`str` is called on it to
758 old_factory = logging.getLogRecordFactory()
765 logging.setLogRecordFactory(record_factory)
820 | funcName | ``%(funcName)s`` | Name of function containing the logging call. |
822 | levelname | ``%(levelname)s`` | Text logging level for the message |
826 | levelno | ``%(levelno)s`` | Numeric logging level for the message |
831 | lineno | ``%(lineno)d`` | Source line number where the logging call was |
844 | | format this yourself. | logging call. Merged with ``args`` to |
851 | | | logging call was issued (if available). |
858 | | | created, relative to the time the logging |
864 | | | of the logging call which resulted in the |
882 information into logging calls. For a usage example, see the section on
883 :ref:`adding contextual information to your logging output <context-info>`.
892 Modifies the message and/or keyword arguments passed to a logging call in
920 The logging module is intended to be thread-safe without any special work
926 module, you may not be able to use logging from within such handlers. This is
943 Choice of these names is entirely up to the developer who is using logging.
957 class MyLogger(logging.getLoggerClass()):
968 representing a logging event is constructed.
982 added to the logging message. If an exception tuple (in the format returned by
987 ``False``. If true, stack information is added to the logging
988 message, including the actual logging call. Note that this is not the same
990 former is stack frames from the bottom of the stack up to the logging call
1008 the logging event with user-defined attributes. These custom attributes can then
1013 logging.basicConfig(format=FORMAT)
1015 logging.warning('Protocol problem: %s', 'connection reset', extra=d)
1024 by the logging system. (See the :class:`Formatter` documentation for more
1025 information on which keys are used by the logging system.)
1075 interpreted as for :func:`debug`. Exception info is added to the logging
1096 the logger's own level. When the need arises to temporarily throttle logging
1098 effect is to disable all logging calls of severity *level* and below, so that
1102 ``logging.disable(logging.NOTSET)`` is called, it effectively removes this
1103 overriding level, so that logging output again depends on the effective
1106 Note that if you have defined any custom logging level higher than
1129 Returns the textual or numeric representation of logging level *level*.
1146 logging logic). This function is used to convert between an integer level
1167 Does basic configuration for the logging system by creating a
1271 Informs the logging system to perform an orderly shutdown by flushing and
1273 further use of the logging system should be made after this call.
1275 When the logging module is imported, it registers this function as an exit
1282 Tells the logging system to use the class *klass* when instantiating a logger.
1288 the :func:`logging.getLogger` API to get your loggers.
1300 a logging event is constructed.
1307 :level: The logging level (numeric).
1308 :fn: The full pathname of the file where the logging call was made.
1309 :lno: The line number in the file where the logging call was made.
1310 :msg: The logging message.
1311 :args: The arguments for the logging message.
1313 :func: The name of the function or method which invoked the logging
1327 ``WARNING``, and is used to handle logging events in the absence of any
1328 logging configuration. The end result is to just print the message to
1338 The :func:`captureWarnings` function can be used to integrate :mod:`logging`
1343 This function is used to turn the capture of warnings by logging on and
1347 be redirected to the logging system. Specifically, a warning will be
1351 If *capture* is ``False``, the redirection of warnings to the logging system
1358 Module :mod:`logging.config`
1359 Configuration API for the logging module.
1361 Module :mod:`logging.handlers`
1362 Useful handlers included with the logging module.
1364 :pep:`282` - A Logging System
1368 `Original Python logging package <https://old.red-dove.com/python_logging.html>`_
1369 This is the original source for the :mod:`logging` package. The version of the
1371 and 2.2.x, which do not include the :mod:`logging` package in the standard