File Doc/library/logging.rst changed (mode: 100644) (index d03cc50d87..45e115316f) |
... |
... |
is the module's name in the Python package namespace. |
69 |
69 |
|
|
70 |
70 |
.. class:: Logger |
.. class:: Logger |
71 |
71 |
|
|
72 |
|
.. attribute:: Logger.propagate |
|
|
72 |
|
.. attribute:: Logger.propagate |
73 |
73 |
|
|
74 |
|
If this evaluates to true, events logged to this logger will be passed to the |
|
75 |
|
handlers of higher level (ancestor) loggers, in addition to any handlers |
|
76 |
|
attached to this logger. Messages are passed directly to the ancestor |
|
77 |
|
loggers' handlers - neither the level nor filters of the ancestor loggers in |
|
78 |
|
question are considered. |
|
|
74 |
|
If this evaluates to true, events logged to this logger will be passed to the |
|
75 |
|
handlers of higher level (ancestor) loggers, in addition to any handlers |
|
76 |
|
attached to this logger. Messages are passed directly to the ancestor |
|
77 |
|
loggers' handlers - neither the level nor filters of the ancestor loggers in |
|
78 |
|
question are considered. |
79 |
79 |
|
|
80 |
|
If this evaluates to false, logging messages are not passed to the handlers |
|
81 |
|
of ancestor loggers. |
|
|
80 |
|
If this evaluates to false, logging messages are not passed to the handlers |
|
81 |
|
of ancestor loggers. |
82 |
82 |
|
|
83 |
|
The constructor sets this attribute to ``True``. |
|
|
83 |
|
The constructor sets this attribute to ``True``. |
84 |
84 |
|
|
85 |
|
.. note:: If you attach a handler to a logger *and* one or more of its |
|
86 |
|
ancestors, it may emit the same record multiple times. In general, you |
|
87 |
|
should not need to attach a handler to more than one logger - if you just |
|
88 |
|
attach it to the appropriate logger which is highest in the logger |
|
89 |
|
hierarchy, then it will see all events logged by all descendant loggers, |
|
90 |
|
provided that their propagate setting is left set to ``True``. A common |
|
91 |
|
scenario is to attach handlers only to the root logger, and to let |
|
92 |
|
propagation take care of the rest. |
|
|
85 |
|
.. note:: If you attach a handler to a logger *and* one or more of its |
|
86 |
|
ancestors, it may emit the same record multiple times. In general, you |
|
87 |
|
should not need to attach a handler to more than one logger - if you just |
|
88 |
|
attach it to the appropriate logger which is highest in the logger |
|
89 |
|
hierarchy, then it will see all events logged by all descendant loggers, |
|
90 |
|
provided that their propagate setting is left set to ``True``. A common |
|
91 |
|
scenario is to attach handlers only to the root logger, and to let |
|
92 |
|
propagation take care of the rest. |
93 |
93 |
|
|
94 |
|
.. method:: Logger.setLevel(lvl) |
|
|
94 |
|
.. method:: Logger.setLevel(lvl) |
95 |
95 |
|
|
96 |
|
Sets the threshold for this logger to *lvl*. Logging messages which are less |
|
97 |
|
severe than *lvl* will be ignored. When a logger is created, the level is set to |
|
98 |
|
:const:`NOTSET` (which causes all messages to be processed when the logger is |
|
99 |
|
the root logger, or delegation to the parent when the logger is a non-root |
|
100 |
|
logger). Note that the root logger is created with level :const:`WARNING`. |
|
|
96 |
|
Sets the threshold for this logger to *lvl*. Logging messages which are less |
|
97 |
|
severe than *lvl* will be ignored. When a logger is created, the level is set to |
|
98 |
|
:const:`NOTSET` (which causes all messages to be processed when the logger is |
|
99 |
|
the root logger, or delegation to the parent when the logger is a non-root |
|
100 |
|
logger). Note that the root logger is created with level :const:`WARNING`. |
101 |
101 |
|
|
102 |
|
The term 'delegation to the parent' means that if a logger has a level of |
|
103 |
|
NOTSET, its chain of ancestor loggers is traversed until either an ancestor with |
|
104 |
|
a level other than NOTSET is found, or the root is reached. |
|
|
102 |
|
The term 'delegation to the parent' means that if a logger has a level of |
|
103 |
|
NOTSET, its chain of ancestor loggers is traversed until either an ancestor with |
|
104 |
|
a level other than NOTSET is found, or the root is reached. |
105 |
105 |
|
|
106 |
|
If an ancestor is found with a level other than NOTSET, then that ancestor's |
|
107 |
|
level is treated as the effective level of the logger where the ancestor search |
|
108 |
|
began, and is used to determine how a logging event is handled. |
|
|
106 |
|
If an ancestor is found with a level other than NOTSET, then that ancestor's |
|
107 |
|
level is treated as the effective level of the logger where the ancestor search |
|
108 |
|
began, and is used to determine how a logging event is handled. |
109 |
109 |
|
|
110 |
|
If the root is reached, and it has a level of NOTSET, then all messages will be |
|
111 |
|
processed. Otherwise, the root's level will be used as the effective level. |
|
|
110 |
|
If the root is reached, and it has a level of NOTSET, then all messages will be |
|
111 |
|
processed. Otherwise, the root's level will be used as the effective level. |
112 |
112 |
|
|
113 |
|
See :ref:`levels` for a list of levels. |
|
|
113 |
|
See :ref:`levels` for a list of levels. |
114 |
114 |
|
|
115 |
|
.. versionchanged:: 3.2 |
|
116 |
|
The *lvl* parameter now accepts a string representation of the |
|
117 |
|
level such as 'INFO' as an alternative to the integer constants |
|
118 |
|
such as :const:`INFO`. Note, however, that levels are internally stored |
|
119 |
|
as integers, and methods such as e.g. :meth:`getEffectiveLevel` and |
|
120 |
|
:meth:`isEnabledFor` will return/expect to be passed integers. |
|
|
115 |
|
.. versionchanged:: 3.2 |
|
116 |
|
The *lvl* parameter now accepts a string representation of the |
|
117 |
|
level such as 'INFO' as an alternative to the integer constants |
|
118 |
|
such as :const:`INFO`. Note, however, that levels are internally stored |
|
119 |
|
as integers, and methods such as e.g. :meth:`getEffectiveLevel` and |
|
120 |
|
:meth:`isEnabledFor` will return/expect to be passed integers. |
121 |
121 |
|
|
122 |
122 |
|
|
123 |
|
.. method:: Logger.isEnabledFor(lvl) |
|
|
123 |
|
.. method:: Logger.isEnabledFor(lvl) |
124 |
124 |
|
|
125 |
|
Indicates if a message of severity *lvl* would be processed by this logger. |
|
126 |
|
This method checks first the module-level level set by |
|
127 |
|
``logging.disable(lvl)`` and then the logger's effective level as determined |
|
128 |
|
by :meth:`getEffectiveLevel`. |
|
|
125 |
|
Indicates if a message of severity *lvl* would be processed by this logger. |
|
126 |
|
This method checks first the module-level level set by |
|
127 |
|
``logging.disable(lvl)`` and then the logger's effective level as determined |
|
128 |
|
by :meth:`getEffectiveLevel`. |
129 |
129 |
|
|
130 |
130 |
|
|
131 |
|
.. method:: Logger.getEffectiveLevel() |
|
|
131 |
|
.. method:: Logger.getEffectiveLevel() |
132 |
132 |
|
|
133 |
|
Indicates the effective level for this logger. If a value other than |
|
134 |
|
:const:`NOTSET` has been set using :meth:`setLevel`, it is returned. Otherwise, |
|
135 |
|
the hierarchy is traversed towards the root until a value other than |
|
136 |
|
:const:`NOTSET` is found, and that value is returned. The value returned is |
|
137 |
|
an integer, typically one of :const:`logging.DEBUG`, :const:`logging.INFO` |
|
138 |
|
etc. |
|
|
133 |
|
Indicates the effective level for this logger. If a value other than |
|
134 |
|
:const:`NOTSET` has been set using :meth:`setLevel`, it is returned. Otherwise, |
|
135 |
|
the hierarchy is traversed towards the root until a value other than |
|
136 |
|
:const:`NOTSET` is found, and that value is returned. The value returned is |
|
137 |
|
an integer, typically one of :const:`logging.DEBUG`, :const:`logging.INFO` |
|
138 |
|
etc. |
139 |
139 |
|
|
140 |
140 |
|
|
141 |
|
.. method:: Logger.getChild(suffix) |
|
|
141 |
|
.. method:: Logger.getChild(suffix) |
142 |
142 |
|
|
143 |
|
Returns a logger which is a descendant to this logger, as determined by the suffix. |
|
144 |
|
Thus, ``logging.getLogger('abc').getChild('def.ghi')`` would return the same |
|
145 |
|
logger as would be returned by ``logging.getLogger('abc.def.ghi')``. This is a |
|
146 |
|
convenience method, useful when the parent logger is named using e.g. ``__name__`` |
|
147 |
|
rather than a literal string. |
|
|
143 |
|
Returns a logger which is a descendant to this logger, as determined by the suffix. |
|
144 |
|
Thus, ``logging.getLogger('abc').getChild('def.ghi')`` would return the same |
|
145 |
|
logger as would be returned by ``logging.getLogger('abc.def.ghi')``. This is a |
|
146 |
|
convenience method, useful when the parent logger is named using e.g. ``__name__`` |
|
147 |
|
rather than a literal string. |
148 |
148 |
|
|
149 |
|
.. versionadded:: 3.2 |
|
|
149 |
|
.. versionadded:: 3.2 |
150 |
150 |
|
|
151 |
151 |
|
|
152 |
|
.. method:: Logger.debug(msg, *args, **kwargs) |
|
|
152 |
|
.. method:: Logger.debug(msg, *args, **kwargs) |
153 |
153 |
|
|
154 |
|
Logs a message with level :const:`DEBUG` on this logger. The *msg* is the |
|
155 |
|
message format string, and the *args* are the arguments which are merged into |
|
156 |
|
*msg* using the string formatting operator. (Note that this means that you can |
|
157 |
|
use keywords in the format string, together with a single dictionary argument.) |
|
|
154 |
|
Logs a message with level :const:`DEBUG` on this logger. The *msg* is the |
|
155 |
|
message format string, and the *args* are the arguments which are merged into |
|
156 |
|
*msg* using the string formatting operator. (Note that this means that you can |
|
157 |
|
use keywords in the format string, together with a single dictionary argument.) |
158 |
158 |
|
|
159 |
|
There are three keyword arguments in *kwargs* which are inspected: |
|
160 |
|
*exc_info*, *stack_info*, and *extra*. |
|
|
159 |
|
There are three keyword arguments in *kwargs* which are inspected: |
|
160 |
|
*exc_info*, *stack_info*, and *extra*. |
161 |
161 |
|
|
162 |
|
If *exc_info* does not evaluate as false, it causes exception information to be |
|
163 |
|
added to the logging message. If an exception tuple (in the format returned by |
|
164 |
|
:func:`sys.exc_info`) or an exception instance is provided, it is used; |
|
165 |
|
otherwise, :func:`sys.exc_info` is called to get the exception information. |
|
|
162 |
|
If *exc_info* does not evaluate as false, it causes exception information to be |
|
163 |
|
added to the logging message. If an exception tuple (in the format returned by |
|
164 |
|
:func:`sys.exc_info`) or an exception instance is provided, it is used; |
|
165 |
|
otherwise, :func:`sys.exc_info` is called to get the exception information. |
166 |
166 |
|
|
167 |
|
The second optional keyword argument is *stack_info*, which defaults to |
|
168 |
|
``False``. If true, stack information is added to the logging |
|
169 |
|
message, including the actual logging call. Note that this is not the same |
|
170 |
|
stack information as that displayed through specifying *exc_info*: The |
|
171 |
|
former is stack frames from the bottom of the stack up to the logging call |
|
172 |
|
in the current thread, whereas the latter is information about stack frames |
|
173 |
|
which have been unwound, following an exception, while searching for |
|
174 |
|
exception handlers. |
|
|
167 |
|
The second optional keyword argument is *stack_info*, which defaults to |
|
168 |
|
``False``. If true, stack information is added to the logging |
|
169 |
|
message, including the actual logging call. Note that this is not the same |
|
170 |
|
stack information as that displayed through specifying *exc_info*: The |
|
171 |
|
former is stack frames from the bottom of the stack up to the logging call |
|
172 |
|
in the current thread, whereas the latter is information about stack frames |
|
173 |
|
which have been unwound, following an exception, while searching for |
|
174 |
|
exception handlers. |
175 |
175 |
|
|
176 |
|
You can specify *stack_info* independently of *exc_info*, e.g. to just show |
|
177 |
|
how you got to a certain point in your code, even when no exceptions were |
|
178 |
|
raised. The stack frames are printed following a header line which says:: |
|
|
176 |
|
You can specify *stack_info* independently of *exc_info*, e.g. to just show |
|
177 |
|
how you got to a certain point in your code, even when no exceptions were |
|
178 |
|
raised. The stack frames are printed following a header line which says:: |
179 |
179 |
|
|
180 |
|
Stack (most recent call last): |
|
|
180 |
|
Stack (most recent call last): |
181 |
181 |
|
|
182 |
|
This mimics the ``Traceback (most recent call last):`` which is used when |
|
183 |
|
displaying exception frames. |
|
|
182 |
|
This mimics the ``Traceback (most recent call last):`` which is used when |
|
183 |
|
displaying exception frames. |
184 |
184 |
|
|
185 |
|
The third keyword argument is *extra* which can be used to pass a |
|
186 |
|
dictionary which is used to populate the __dict__ of the LogRecord created for |
|
187 |
|
the logging event with user-defined attributes. These custom attributes can then |
|
188 |
|
be used as you like. For example, they could be incorporated into logged |
|
189 |
|
messages. For example:: |
|
|
185 |
|
The third keyword argument is *extra* which can be used to pass a |
|
186 |
|
dictionary which is used to populate the __dict__ of the LogRecord created for |
|
187 |
|
the logging event with user-defined attributes. These custom attributes can then |
|
188 |
|
be used as you like. For example, they could be incorporated into logged |
|
189 |
|
messages. For example:: |
190 |
190 |
|
|
191 |
|
FORMAT = '%(asctime)-15s %(clientip)s %(user)-8s %(message)s' |
|
192 |
|
logging.basicConfig(format=FORMAT) |
|
193 |
|
d = {'clientip': '192.168.0.1', 'user': 'fbloggs'} |
|
194 |
|
logger = logging.getLogger('tcpserver') |
|
195 |
|
logger.warning('Protocol problem: %s', 'connection reset', extra=d) |
|
|
191 |
|
FORMAT = '%(asctime)-15s %(clientip)s %(user)-8s %(message)s' |
|
192 |
|
logging.basicConfig(format=FORMAT) |
|
193 |
|
d = {'clientip': '192.168.0.1', 'user': 'fbloggs'} |
|
194 |
|
logger = logging.getLogger('tcpserver') |
|
195 |
|
logger.warning('Protocol problem: %s', 'connection reset', extra=d) |
196 |
196 |
|
|
197 |
|
would print something like :: |
|
|
197 |
|
would print something like :: |
198 |
198 |
|
|
199 |
|
2006-02-08 22:20:02,165 192.168.0.1 fbloggs Protocol problem: connection reset |
|
|
199 |
|
2006-02-08 22:20:02,165 192.168.0.1 fbloggs Protocol problem: connection reset |
200 |
200 |
|
|
201 |
|
The keys in the dictionary passed in *extra* should not clash with the keys used |
|
202 |
|
by the logging system. (See the :class:`Formatter` documentation for more |
|
203 |
|
information on which keys are used by the logging system.) |
|
|
201 |
|
The keys in the dictionary passed in *extra* should not clash with the keys used |
|
202 |
|
by the logging system. (See the :class:`Formatter` documentation for more |
|
203 |
|
information on which keys are used by the logging system.) |
204 |
204 |
|
|
205 |
|
If you choose to use these attributes in logged messages, you need to exercise |
|
206 |
|
some care. In the above example, for instance, the :class:`Formatter` has been |
|
207 |
|
set up with a format string which expects 'clientip' and 'user' in the attribute |
|
208 |
|
dictionary of the LogRecord. If these are missing, the message will not be |
|
209 |
|
logged because a string formatting exception will occur. So in this case, you |
|
210 |
|
always need to pass the *extra* dictionary with these keys. |
|
|
205 |
|
If you choose to use these attributes in logged messages, you need to exercise |
|
206 |
|
some care. In the above example, for instance, the :class:`Formatter` has been |
|
207 |
|
set up with a format string which expects 'clientip' and 'user' in the attribute |
|
208 |
|
dictionary of the LogRecord. If these are missing, the message will not be |
|
209 |
|
logged because a string formatting exception will occur. So in this case, you |
|
210 |
|
always need to pass the *extra* dictionary with these keys. |
211 |
211 |
|
|
212 |
|
While this might be annoying, this feature is intended for use in specialized |
|
213 |
|
circumstances, such as multi-threaded servers where the same code executes in |
|
214 |
|
many contexts, and interesting conditions which arise are dependent on this |
|
215 |
|
context (such as remote client IP address and authenticated user name, in the |
|
216 |
|
above example). In such circumstances, it is likely that specialized |
|
217 |
|
:class:`Formatter`\ s would be used with particular :class:`Handler`\ s. |
|
|
212 |
|
While this might be annoying, this feature is intended for use in specialized |
|
213 |
|
circumstances, such as multi-threaded servers where the same code executes in |
|
214 |
|
many contexts, and interesting conditions which arise are dependent on this |
|
215 |
|
context (such as remote client IP address and authenticated user name, in the |
|
216 |
|
above example). In such circumstances, it is likely that specialized |
|
217 |
|
:class:`Formatter`\ s would be used with particular :class:`Handler`\ s. |
218 |
218 |
|
|
219 |
|
.. versionadded:: 3.2 |
|
220 |
|
The *stack_info* parameter was added. |
|
|
219 |
|
.. versionadded:: 3.2 |
|
220 |
|
The *stack_info* parameter was added. |
221 |
221 |
|
|
222 |
|
.. versionchanged:: 3.5 |
|
223 |
|
The *exc_info* parameter can now accept exception instances. |
|
|
222 |
|
.. versionchanged:: 3.5 |
|
223 |
|
The *exc_info* parameter can now accept exception instances. |
224 |
224 |
|
|
225 |
225 |
|
|
226 |
|
.. method:: Logger.info(msg, *args, **kwargs) |
|
|
226 |
|
.. method:: Logger.info(msg, *args, **kwargs) |
227 |
227 |
|
|
228 |
|
Logs a message with level :const:`INFO` on this logger. The arguments are |
|
229 |
|
interpreted as for :meth:`debug`. |
|
|
228 |
|
Logs a message with level :const:`INFO` on this logger. The arguments are |
|
229 |
|
interpreted as for :meth:`debug`. |
230 |
230 |
|
|
231 |
231 |
|
|
232 |
|
.. method:: Logger.warning(msg, *args, **kwargs) |
|
|
232 |
|
.. method:: Logger.warning(msg, *args, **kwargs) |
233 |
233 |
|
|
234 |
|
Logs a message with level :const:`WARNING` on this logger. The arguments are |
|
235 |
|
interpreted as for :meth:`debug`. |
|
|
234 |
|
Logs a message with level :const:`WARNING` on this logger. The arguments are |
|
235 |
|
interpreted as for :meth:`debug`. |
236 |
236 |
|
|
237 |
|
.. note:: There is an obsolete method ``warn`` which is functionally |
|
238 |
|
identical to ``warning``. As ``warn`` is deprecated, please do not use |
|
239 |
|
it - use ``warning`` instead. |
|
|
237 |
|
.. note:: There is an obsolete method ``warn`` which is functionally |
|
238 |
|
identical to ``warning``. As ``warn`` is deprecated, please do not use |
|
239 |
|
it - use ``warning`` instead. |
240 |
240 |
|
|
241 |
|
.. method:: Logger.error(msg, *args, **kwargs) |
|
|
241 |
|
.. method:: Logger.error(msg, *args, **kwargs) |
242 |
242 |
|
|
243 |
|
Logs a message with level :const:`ERROR` on this logger. The arguments are |
|
244 |
|
interpreted as for :meth:`debug`. |
|
|
243 |
|
Logs a message with level :const:`ERROR` on this logger. The arguments are |
|
244 |
|
interpreted as for :meth:`debug`. |
245 |
245 |
|
|
246 |
246 |
|
|
247 |
|
.. method:: Logger.critical(msg, *args, **kwargs) |
|
|
247 |
|
.. method:: Logger.critical(msg, *args, **kwargs) |
248 |
248 |
|
|
249 |
|
Logs a message with level :const:`CRITICAL` on this logger. The arguments are |
|
250 |
|
interpreted as for :meth:`debug`. |
|
|
249 |
|
Logs a message with level :const:`CRITICAL` on this logger. The arguments are |
|
250 |
|
interpreted as for :meth:`debug`. |
251 |
251 |
|
|
252 |
252 |
|
|
253 |
|
.. method:: Logger.log(lvl, msg, *args, **kwargs) |
|
|
253 |
|
.. method:: Logger.log(lvl, msg, *args, **kwargs) |
254 |
254 |
|
|
255 |
|
Logs a message with integer level *lvl* on this logger. The other arguments are |
|
256 |
|
interpreted as for :meth:`debug`. |
|
|
255 |
|
Logs a message with integer level *lvl* on this logger. The other arguments are |
|
256 |
|
interpreted as for :meth:`debug`. |
257 |
257 |
|
|
258 |
258 |
|
|
259 |
|
.. method:: Logger.exception(msg, *args, **kwargs) |
|
|
259 |
|
.. method:: Logger.exception(msg, *args, **kwargs) |
260 |
260 |
|
|
261 |
|
Logs a message with level :const:`ERROR` on this logger. The arguments are |
|
262 |
|
interpreted as for :meth:`debug`. Exception info is added to the logging |
|
263 |
|
message. This method should only be called from an exception handler. |
|
|
261 |
|
Logs a message with level :const:`ERROR` on this logger. The arguments are |
|
262 |
|
interpreted as for :meth:`debug`. Exception info is added to the logging |
|
263 |
|
message. This method should only be called from an exception handler. |
264 |
264 |
|
|
265 |
265 |
|
|
266 |
|
.. method:: Logger.addFilter(filt) |
|
|
266 |
|
.. method:: Logger.addFilter(filt) |
267 |
267 |
|
|
268 |
|
Adds the specified filter *filt* to this logger. |
|
|
268 |
|
Adds the specified filter *filt* to this logger. |
269 |
269 |
|
|
270 |
270 |
|
|
271 |
|
.. method:: Logger.removeFilter(filt) |
|
|
271 |
|
.. method:: Logger.removeFilter(filt) |
272 |
272 |
|
|
273 |
|
Removes the specified filter *filt* from this logger. |
|
|
273 |
|
Removes the specified filter *filt* from this logger. |
274 |
274 |
|
|
275 |
275 |
|
|
276 |
|
.. method:: Logger.filter(record) |
|
|
276 |
|
.. method:: Logger.filter(record) |
277 |
277 |
|
|
278 |
|
Applies this logger's filters to the record and returns a true value if the |
|
279 |
|
record is to be processed. The filters are consulted in turn, until one of |
|
280 |
|
them returns a false value. If none of them return a false value, the record |
|
281 |
|
will be processed (passed to handlers). If one returns a false value, no |
|
282 |
|
further processing of the record occurs. |
|
|
278 |
|
Applies this logger's filters to the record and returns a true value if the |
|
279 |
|
record is to be processed. The filters are consulted in turn, until one of |
|
280 |
|
them returns a false value. If none of them return a false value, the record |
|
281 |
|
will be processed (passed to handlers). If one returns a false value, no |
|
282 |
|
further processing of the record occurs. |
283 |
283 |
|
|
284 |
284 |
|
|
285 |
|
.. method:: Logger.addHandler(hdlr) |
|
|
285 |
|
.. method:: Logger.addHandler(hdlr) |
286 |
286 |
|
|
287 |
|
Adds the specified handler *hdlr* to this logger. |
|
|
287 |
|
Adds the specified handler *hdlr* to this logger. |
288 |
288 |
|
|
289 |
289 |
|
|
290 |
|
.. method:: Logger.removeHandler(hdlr) |
|
|
290 |
|
.. method:: Logger.removeHandler(hdlr) |
291 |
291 |
|
|
292 |
|
Removes the specified handler *hdlr* from this logger. |
|
|
292 |
|
Removes the specified handler *hdlr* from this logger. |
293 |
293 |
|
|
294 |
294 |
|
|
295 |
|
.. method:: Logger.findCaller(stack_info=False) |
|
|
295 |
|
.. method:: Logger.findCaller(stack_info=False) |
296 |
296 |
|
|
297 |
|
Finds the caller's source filename and line number. Returns the filename, line |
|
298 |
|
number, function name and stack information as a 4-element tuple. The stack |
|
299 |
|
information is returned as ``None`` unless *stack_info* is ``True``. |
|
|
297 |
|
Finds the caller's source filename and line number. Returns the filename, line |
|
298 |
|
number, function name and stack information as a 4-element tuple. The stack |
|
299 |
|
information is returned as ``None`` unless *stack_info* is ``True``. |
300 |
300 |
|
|
301 |
301 |
|
|
302 |
|
.. method:: Logger.handle(record) |
|
|
302 |
|
.. method:: Logger.handle(record) |
303 |
303 |
|
|
304 |
|
Handles a record by passing it to all handlers associated with this logger and |
|
305 |
|
its ancestors (until a false value of *propagate* is found). This method is used |
|
306 |
|
for unpickled records received from a socket, as well as those created locally. |
|
307 |
|
Logger-level filtering is applied using :meth:`~Logger.filter`. |
|
|
304 |
|
Handles a record by passing it to all handlers associated with this logger and |
|
305 |
|
its ancestors (until a false value of *propagate* is found). This method is used |
|
306 |
|
for unpickled records received from a socket, as well as those created locally. |
|
307 |
|
Logger-level filtering is applied using :meth:`~Logger.filter`. |
308 |
308 |
|
|
309 |
309 |
|
|
310 |
|
.. method:: Logger.makeRecord(name, lvl, fn, lno, msg, args, exc_info, func=None, extra=None, sinfo=None) |
|
|
310 |
|
.. method:: Logger.makeRecord(name, lvl, fn, lno, msg, args, exc_info, func=None, extra=None, sinfo=None) |
311 |
311 |
|
|
312 |
|
This is a factory method which can be overridden in subclasses to create |
|
313 |
|
specialized :class:`LogRecord` instances. |
|
|
312 |
|
This is a factory method which can be overridden in subclasses to create |
|
313 |
|
specialized :class:`LogRecord` instances. |
314 |
314 |
|
|
315 |
|
.. method:: Logger.hasHandlers() |
|
|
315 |
|
.. method:: Logger.hasHandlers() |
316 |
316 |
|
|
317 |
|
Checks to see if this logger has any handlers configured. This is done by |
|
318 |
|
looking for handlers in this logger and its parents in the logger hierarchy. |
|
319 |
|
Returns ``True`` if a handler was found, else ``False``. The method stops searching |
|
320 |
|
up the hierarchy whenever a logger with the 'propagate' attribute set to |
|
321 |
|
false is found - that will be the last logger which is checked for the |
|
322 |
|
existence of handlers. |
|
|
317 |
|
Checks to see if this logger has any handlers configured. This is done by |
|
318 |
|
looking for handlers in this logger and its parents in the logger hierarchy. |
|
319 |
|
Returns ``True`` if a handler was found, else ``False``. The method stops searching |
|
320 |
|
up the hierarchy whenever a logger with the 'propagate' attribute set to |
|
321 |
|
false is found - that will be the last logger which is checked for the |
|
322 |
|
existence of handlers. |
323 |
323 |
|
|
324 |
|
.. versionadded:: 3.2 |
|
|
324 |
|
.. versionadded:: 3.2 |
325 |
325 |
|
|
326 |
326 |
|
|
327 |
327 |
.. _levels: |
.. _levels: |
|
... |
... |
with the :mod:`warnings` module. |
1256 |
1256 |
package available from this site is suitable for use with Python 1.5.2, 2.1.x |
package available from this site is suitable for use with Python 1.5.2, 2.1.x |
1257 |
1257 |
and 2.2.x, which do not include the :mod:`logging` package in the standard |
and 2.2.x, which do not include the :mod:`logging` package in the standard |
1258 |
1258 |
library. |
library. |
1259 |
|
|
|