@@ -244,16 +244,16 @@ With the logger object configured, the following methods create log messages:
244
244
methods listed above, but this is how to log at custom log levels.
245
245
246
246
:func: `getLogger ` returns a reference to a logger instance with the specified
247
- if it it is provided, or ``root `` if not. The names are period-separated
247
+ if it is provided, or ``root `` if not. The names are period-separated
248
248
hierarchical structures. Multiple calls to :func: `getLogger ` with the same name
249
249
will return a reference to the same logger object. Loggers that are further
250
250
down in the hierarchical list are children of loggers higher up in the list.
251
251
For example, given a logger with a name of ``foo ``, loggers with names of
252
- ``foo.bar ``, ``foo.bar.baz ``, and ``foo.bam `` are all children of ``foo ``.
253
- Child loggers propagate messages up to their parent loggers. Because of this,
254
- it is unnecessary to define and configure all the loggers an application uses.
255
- It is sufficient to configure a top-level logger and create child loggers as
256
- needed.
252
+ ``foo.bar ``, ``foo.bar.baz ``, and ``foo.bam `` are all descendants of ``foo ``.
253
+ Child loggers propagate messages up to the handlers associated with their
254
+ ancestor loggers. Because of this, it is unnecessary to define and configure
255
+ handlers for all the loggers an application uses. It is sufficient to
256
+ configure handlers for a top-level logger and create child loggers as needed.
257
257
258
258
259
259
Handlers
@@ -281,15 +281,16 @@ custom handlers) are the following configuration methods:
281
281
are there two :func: `setLevel ` methods? The level set in the logger
282
282
determines which severity of messages it will pass to its handlers. The level
283
283
set in each handler determines which messages that handler will send on.
284
- :func: `setFormatter ` selects a Formatter object for this handler to use.
284
+
285
+ * :func: `setFormatter ` selects a Formatter object for this handler to use.
285
286
286
287
* :func: `addFilter ` and :func: `removeFilter ` respectively configure and
287
288
deconfigure filter objects on handlers.
288
289
289
- Application code should not directly instantiate and use handlers. Instead, the
290
- :class: `Handler ` class is a base class that defines the interface that all
291
- Handlers should have and establishes some default behavior that child classes
292
- can use (or override).
290
+ Application code should not directly instantiate and use instances of
291
+ :class: `Handler `. Instead, the : class: ` Handler ` class is a base class that
292
+ defines the interface that all handlers should have and establishes some
293
+ default behavior that child classes can use (or override).
293
294
294
295
295
296
Formatters
@@ -521,7 +522,9 @@ support desk staff, system administrators, developers). Handlers are passed
521
522
can have zero, one or more handlers associated with it (via the
522
523
:meth: `addHandler ` method of :class: `Logger `). In addition to any handlers
523
524
directly associated with a logger, *all handlers associated with all ancestors
524
- of the logger * are called to dispatch the message.
525
+ of the logger * are called to dispatch the message (unless the *propagate * flag
526
+ for a logger is set to a false value, at which point the passing to ancestor
527
+ handlers stops).
525
528
526
529
Just as for loggers, handlers can have levels associated with them. A handler's
527
530
level acts as a filter in the same way as a logger's level does. If a handler
@@ -849,8 +852,8 @@ instantiated directly, but always through the module-level function
849
852
.. attribute :: Logger.propagate
850
853
851
854
If this evaluates to false, logging messages are not passed by this logger or by
852
- child loggers to higher level (ancestor) loggers. The constructor sets this
853
- attribute to 1.
855
+ its child loggers to the handlers of higher level (ancestor) loggers. The
856
+ constructor sets this attribute to 1.
854
857
855
858
856
859
.. method :: Logger.setLevel(lvl)
@@ -889,6 +892,16 @@ instantiated directly, but always through the module-level function
889
892
:const: `NOTSET ` is found, and that value is returned.
890
893
891
894
895
+ .. method :: Logger.getChild(suffix)
896
+
897
+ Returns a logger which is a descendant to this logger, as determined by the suffix.
898
+ Thus, ``logging.getLogger('abc').getChild('def.ghi') `` would return the same
899
+ logger as would be returned by ``logging.getLogger('abc.def.ghi') ``. This is a
900
+ convenience method, useful when the parent logger is named using e.g. ``__name__ ``
901
+ rather than a literal string.
902
+
903
+ .. versionadded :: 3.2
904
+
892
905
.. method :: Logger.debug(msg, *args, **kwargs)
893
906
894
907
Logs a message with level :const: `DEBUG ` on this logger. The *msg * is the
@@ -2012,8 +2025,11 @@ supports sending logging messages to a remote or local Unix syslog.
2012
2025
or integers - if strings are passed, internal mapping dictionaries are
2013
2026
used to convert them to integers.
2014
2027
2015
- **Priorities **
2028
+ The symbolic ``LOG_ `` values are defined in :class: `SysLogHandler ` and
2029
+ mirror the values defined in the ``sys/syslog.h `` header file.
2016
2030
2031
+ +------------------------------------------+
2032
+ | Priorities |
2017
2033
+--------------------------+---------------+
2018
2034
| Name (string) | Symbolic value|
2019
2035
+==========================+===============+
@@ -2034,8 +2050,8 @@ supports sending logging messages to a remote or local Unix syslog.
2034
2050
| ``warn `` or ``warning `` | LOG_WARNING |
2035
2051
+--------------------------+---------------+
2036
2052
2037
- ** Facilities **
2038
-
2053
+ +-------------------------------+
2054
+ | Facilities |
2039
2055
+---------------+---------------+
2040
2056
| Name (string) | Symbolic value|
2041
2057
+===============+===============+
@@ -2481,6 +2497,11 @@ methods of :class:`Logger`, i.e. :meth:`debug`, :meth:`info`, :meth:`warning`,
2481
2497
methods have the same signatures as their counterparts in :class: `Logger `, so
2482
2498
you can use the two types of instances interchangeably.
2483
2499
2500
+ .. versionchanged :: 2.7
2501
+
2502
+ The :meth: `isEnabledFor ` method was added to :class: `LoggerAdapter `. This method
2503
+ delegates to the underlying logger.
2504
+
2484
2505
2485
2506
Thread Safety
2486
2507
-------------
0 commit comments