@@ -928,14 +928,14 @@ functions.
928
928
Logs a message with level *level * on the root logger. The other arguments are
929
929
interpreted as for :func: `debug `.
930
930
931
- PLEASE NOTE : The above module-level functions which delegate to the root
932
- logger should *not * be used in threads, in versions of Python earlier than
933
- 2.7.1 and 3.2, unless at least one handler has been added to the root
934
- logger *before * the threads are started. These convenience functions call
935
- :func: `basicConfig ` to ensure that at least one handler is available; in
936
- earlier versions of Python, this can (under rare circumstances) lead to
937
- handlers being added multiple times to the root logger, which can in turn
938
- lead to multiple messages for the same event.
931
+ .. note : : The above module-level functions which delegate to the root
932
+ logger should *not * be used in threads, in versions of Python earlier
933
+ than 2.7.1 and 3.2, unless at least one handler has been added to the
934
+ root logger *before * the threads are started. These convenience functions
935
+ call :func: `basicConfig ` to ensure that at least one handler is
936
+ available; in earlier versions of Python, this can (under rare
937
+ circumstances) lead to handlers being added multiple times to the root
938
+ logger, which can in turn lead to multiple messages for the same event.
939
939
940
940
.. function :: disable(lvl)
941
941
@@ -991,12 +991,12 @@ functions.
991
991
This function does nothing if the root logger already has handlers
992
992
configured for it.
993
993
994
- PLEASE NOTE : This function should be called from the main thread
995
- before other threads are started. In versions of Python prior to
996
- 2.7.1 and 3.2, if this function is called from multiple threads,
997
- it is possible (in rare circumstances) that a handler will be added
998
- to the root logger more than once, leading to unexpected results
999
- such as messages being duplicated in the log.
994
+ .. note : : This function should be called from the main thread
995
+ before other threads are started. In versions of Python prior to
996
+ 2.7.1 and 3.2, if this function is called from multiple threads,
997
+ it is possible (in rare circumstances) that a handler will be added
998
+ to the root logger more than once, leading to unexpected results
999
+ such as messages being duplicated in the log.
1000
1000
1001
1001
The following keyword arguments are supported.
1002
1002
@@ -1080,6 +1080,21 @@ functions.
1080
1080
:kwargs: Additional keyword arguments.
1081
1081
1082
1082
1083
+ Module-Level Attributes
1084
+ -----------------------
1085
+
1086
+ .. attribute :: lastResort
1087
+
1088
+ A "handler of last resort" is available through this attribute. This
1089
+ is a :class: `StreamHandler ` writing to ``sys.stderr `` with a level of
1090
+ ``WARNING ``, and is used to handle logging events in the absence of any
1091
+ logging configuration. The end result is to just print the message to
1092
+ ``sys.stderr ``. This replaces the earlier error message saying that
1093
+ "no handlers could be found for logger XYZ". If you need the earlier
1094
+ behaviour for some reason, ``lastResort `` can be set to ``None ``.
1095
+
1096
+ .. versionadded :: 3.2
1097
+
1083
1098
Integration with the warnings module
1084
1099
------------------------------------
1085
1100
0 commit comments