• 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
37 >>> import logging
38 >>> logging.warning('Watch out!')
42 unfamiliar with logging, the best way to get to grips with it is to view the
63 ``logging.getLogger(name)``. Multiple calls to :func:`getLogger` with the same
74 ``logging.getLogger(__name__)``. That's because in a module, ``__name__``
88 If this evaluates to false, logging messages are not passed to the handlers
93 ``logging.getLogger('A.B.C').error(...)`` will [subject to passing that logger's
113 Sets the threshold for this logger to *level*. Logging messages which are less
114 severe than *level* will be ignored; logging messages which have severity *level*
129 began, and is used to determine how a logging event is handled.
148 ``logging.disable(level)`` and then the logger's effective level as determined
158 an integer, typically one of :const:`logging.DEBUG`, :const:`logging.INFO`
165 Thus, ``logging.getLogger('abc').getChild('def.ghi')`` would return the same
166 logger as would be returned by ``logging.getLogger('abc.def.ghi')``. This is a
185 added to the logging message. If an exception tuple (in the format returned by
190 ``False``. If true, stack information is added to the logging
191 message, including the actual logging call. Note that this is not the same
193 former is stack frames from the bottom of the stack up to the logging call
212 created for the logging event. This can be used in logging helpers so that
219 created for the logging event with user-defined attributes. These custom
224 logging.basicConfig(format=FORMAT)
226 logger = logging.getLogger('tcpserver')
236 by the logging system. (See the section on :ref:`logrecord-attributes` for more
237 information on which keys are used by the logging system.)
303 interpreted as for :meth:`debug`. Exception info is added to the logging
345 when calling logging APIs from helper/wrapper code, so that the information
379 Logging Levels
382 The numeric values of logging levels are given in the following table. These are
442 Sets the threshold for this handler to *level*. Logging messages which are
481 Ensure all logging output has been flushed. This version does nothing and is
495 Conditionally emits the specified logging record, depending on filters which may
505 what is mostly wanted for a logging system - most users will not care about
506 errors in the logging system, they are more interested in application
521 Do whatever it takes to actually log the specified logging record. This version
528 the logging API which might do locking, because that might result in a
531 * Logging configuration APIs acquire the module-level lock, and then
534 * Many logging APIs lock the module-level lock. If such an API is called
541 For a list of handlers included as standard, see :mod:`logging.handlers`.
548 .. currentmodule:: logging
555 the message in the logging call. To have additional items of information in the
587 ``logging.Formatter('%(ip)s %(message)s', defaults={"ip": None})``
595 For example: ``logging.Formatter('%(asctime)s - %(message)s', style='{')``.
639 want all logging times to be shown in GMT, set the ``converter``
783 :param level: The :ref:`numeric level <levels>` of the logging event
791 where the logging call was made.
795 where the logging call was made.
813 from which the logging call was invoked.
818 up to the logging call.
825 argument to the logging call is not a string, :func:`str` is called on it to
839 old_factory = logging.getLogRecordFactory()
846 logging.setLogRecordFactory(record_factory)
901 | funcName | ``%(funcName)s`` | Name of function containing the logging call. |
903 | levelname | ``%(levelname)s`` | Text logging level for the message |
907 | levelno | ``%(levelno)s`` | Numeric logging level for the message |
912 | lineno | ``%(lineno)d`` | Source line number where the logging call was |
925 | | format this yourself. | logging call. Merged with ``args`` to |
932 | | | logging call was issued (if available). |
939 | | | created, relative to the time the logging |
945 | | | of the logging call which resulted in the |
963 information into logging calls. For a usage example, see the section on
964 :ref:`adding contextual information to your logging output <context-info>`.
973 Modifies the message and/or keyword arguments passed to a logging call in
1001 The logging module is intended to be thread-safe without any special work
1007 module, you may not be able to use logging from within such handlers. This is
1024 Choice of these names is entirely up to the developer who is using logging.
1038 class MyLogger(logging.getLoggerClass()):
1049 representing a logging event is constructed.
1063 added to the logging message. If an exception tuple (in the format returned by
1068 ``False``. If true, stack information is added to the logging
1069 message, including the actual logging call. Note that this is not the same
1071 former is stack frames from the bottom of the stack up to the logging call
1089 the logging event with user-defined attributes. These custom attributes can then
1094 logging.basicConfig(format=FORMAT)
1096 logging.warning('Protocol problem: %s', 'connection reset', extra=d)
1105 by the logging system. (See the :class:`Formatter` documentation for more
1106 information on which keys are used by the logging system.)
1160 interpreted as for :func:`debug`. Exception info is added to the logging
1171 the logger's own level. When the need arises to temporarily throttle logging
1173 effect is to disable all logging calls of severity *level* and below, so that
1177 ``logging.disable(logging.NOTSET)`` is called, it effectively removes this
1178 overriding level, so that logging output again depends on the effective
1181 Note that if you have defined any custom logging level higher than
1204 Returns a mapping from level names to their corresponding logging levels. For example, the
1212 Returns the textual or numeric representation of logging level *level*.
1229 logging logic). This function is used to convert between an integer level
1250 Does basic configuration for the logging system by creating a
1354 Informs the logging system to perform an orderly shutdown by flushing and
1356 further use of the logging system should be made after this call.
1358 When the logging module is imported, it registers this function as an exit
1365 Tells the logging system to use the class *klass* when instantiating a logger.
1371 the :func:`logging.getLogger` API to get your loggers.
1383 a logging event is constructed.
1390 :level: The logging level (numeric).
1391 :fn: The full pathname of the file where the logging call was made.
1392 :lno: The line number in the file where the logging call was made.
1393 :msg: The logging message.
1394 :args: The arguments for the logging message.
1396 :func: The name of the function or method which invoked the logging
1410 ``WARNING``, and is used to handle logging events in the absence of any
1411 logging configuration. The end result is to just print the message to
1421 The :func:`captureWarnings` function can be used to integrate :mod:`logging`
1426 This function is used to turn the capture of warnings by logging on and
1430 be redirected to the logging system. Specifically, a warning will be
1434 If *capture* is ``False``, the redirection of warnings to the logging system
1441 Module :mod:`logging.config`
1442 Configuration API for the logging module.
1444 Module :mod:`logging.handlers`
1445 Useful handlers included with the logging module.
1447 :pep:`282` - A Logging System
1451 `Original Python logging package <https://old.red-dove.com/python_logging.html>`_
1452 This is the original source for the :mod:`logging` package. The version of the
1454 and 2.2.x, which do not include the :mod:`logging` package in the standard