2013-03-22 12:19:54 -03:00
|
|
|
# Copyright 2001-2013 by Vinay Sajip. All Rights Reserved.
|
2002-11-13 12:15:58 -04:00
|
|
|
#
|
|
|
|
# Permission to use, copy, modify, and distribute this software and its
|
|
|
|
# documentation for any purpose and without fee is hereby granted,
|
|
|
|
# provided that the above copyright notice appear in all copies and that
|
|
|
|
# both that copyright notice and this permission notice appear in
|
|
|
|
# supporting documentation, and that the name of Vinay Sajip
|
|
|
|
# not be used in advertising or publicity pertaining to distribution
|
|
|
|
# of the software without specific, written prior permission.
|
|
|
|
# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
|
|
|
# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
|
|
# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
|
|
|
# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
|
|
|
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
"""
|
2004-02-28 12:07:46 -04:00
|
|
|
Configuration functions for the logging package for Python. The core package
|
|
|
|
is based on PEP 282 and comments thereto in comp.lang.python, and influenced
|
|
|
|
by Apache's log4j system.
|
2002-11-13 12:15:58 -04:00
|
|
|
|
2013-03-22 12:19:54 -03:00
|
|
|
Copyright (C) 2001-2013 Vinay Sajip. All Rights Reserved.
|
2002-11-13 12:15:58 -04:00
|
|
|
|
|
|
|
To use, simply 'import logging' and log away!
|
|
|
|
"""
|
|
|
|
|
2011-11-07 14:43:05 -04:00
|
|
|
import sys, logging, logging.handlers, socket, struct, traceback, re
|
|
|
|
import io
|
2005-02-18 07:54:46 -04:00
|
|
|
|
|
|
|
try:
|
2008-05-25 10:05:15 -03:00
|
|
|
import _thread as thread
|
2005-02-18 07:54:46 -04:00
|
|
|
import threading
|
2011-04-26 15:34:04 -03:00
|
|
|
except ImportError: #pragma: no cover
|
2005-02-18 07:54:46 -04:00
|
|
|
thread = None
|
2002-11-13 12:15:58 -04:00
|
|
|
|
2008-05-11 23:31:37 -03:00
|
|
|
from socketserver import ThreadingTCPServer, StreamRequestHandler
|
2002-11-13 12:15:58 -04:00
|
|
|
|
|
|
|
|
|
|
|
DEFAULT_LOGGING_CONFIG_PORT = 9030
|
|
|
|
|
2004-02-20 09:16:36 -04:00
|
|
|
if sys.platform == "win32":
|
|
|
|
RESET_ERROR = 10054 #WSAECONNRESET
|
|
|
|
else:
|
|
|
|
RESET_ERROR = 104 #ECONNRESET
|
|
|
|
|
2002-11-13 12:15:58 -04:00
|
|
|
#
|
|
|
|
# The following code implements a socket listener for on-the-fly
|
|
|
|
# reconfiguration of logging.
|
|
|
|
#
|
|
|
|
# _listener holds the server object doing the listening
|
|
|
|
_listener = None
|
|
|
|
|
2009-06-08 05:58:54 -03:00
|
|
|
def fileConfig(fname, defaults=None, disable_existing_loggers=True):
|
2002-11-13 12:15:58 -04:00
|
|
|
"""
|
|
|
|
Read the logging configuration from a ConfigParser-format file.
|
|
|
|
|
|
|
|
This can be called several times from an application, allowing an end user
|
|
|
|
the ability to select from various pre-canned configurations (if the
|
|
|
|
developer provides a mechanism to present the choices and load the chosen
|
|
|
|
configuration).
|
|
|
|
"""
|
2008-05-14 19:59:42 -03:00
|
|
|
import configparser
|
2002-11-13 12:15:58 -04:00
|
|
|
|
2012-10-09 05:06:03 -03:00
|
|
|
if isinstance(fname, configparser.RawConfigParser):
|
|
|
|
cp = fname
|
2002-11-13 12:15:58 -04:00
|
|
|
else:
|
2012-10-09 05:06:03 -03:00
|
|
|
cp = configparser.ConfigParser(defaults)
|
|
|
|
if hasattr(fname, 'readline'):
|
|
|
|
cp.read_file(fname)
|
|
|
|
else:
|
|
|
|
cp.read(fname)
|
2006-01-16 17:28:37 -04:00
|
|
|
|
|
|
|
formatters = _create_formatters(cp)
|
|
|
|
|
|
|
|
# critical section
|
2002-11-13 12:15:58 -04:00
|
|
|
logging._acquireLock()
|
|
|
|
try:
|
2006-01-16 17:28:37 -04:00
|
|
|
logging._handlers.clear()
|
Merge current trunk into p3yk. This includes the PyNumber_Index API change,
which unfortunately means the errors from the bytes type change somewhat:
bytes([300]) still raises a ValueError, but bytes([10**100]) now raises a
TypeError (either that, or bytes(1.0) also raises a ValueError --
PyNumber_AsSsize_t() can only raise one type of exception.)
Merged revisions 51188-51433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r51189 | kurt.kaiser | 2006-08-10 19:11:09 +0200 (Thu, 10 Aug 2006) | 4 lines
Retrieval of previous shell command was not always preserving indentation
since 1.2a1) Patch 1528468 Tal Einat.
........
r51190 | guido.van.rossum | 2006-08-10 19:41:07 +0200 (Thu, 10 Aug 2006) | 3 lines
Chris McDonough's patch to defend against certain DoS attacks on FieldStorage.
SF bug #1112549.
........
r51191 | guido.van.rossum | 2006-08-10 19:42:50 +0200 (Thu, 10 Aug 2006) | 2 lines
News item for SF bug 1112549.
........
r51192 | guido.van.rossum | 2006-08-10 20:09:25 +0200 (Thu, 10 Aug 2006) | 2 lines
Fix title -- it's rc1, not beta3.
........
r51194 | martin.v.loewis | 2006-08-10 21:04:00 +0200 (Thu, 10 Aug 2006) | 3 lines
Update dangling references to the 3.2 database to
mention that this is UCD 4.1 now.
........
r51195 | tim.peters | 2006-08-11 00:45:34 +0200 (Fri, 11 Aug 2006) | 6 lines
Followup to bug #1069160.
PyThreadState_SetAsyncExc(): internal correctness changes wrt
refcount safety and deadlock avoidance. Also added a basic test
case (relying on ctypes) and repaired the docs.
........
r51196 | tim.peters | 2006-08-11 00:48:45 +0200 (Fri, 11 Aug 2006) | 2 lines
Whitespace normalization.
........
r51197 | tim.peters | 2006-08-11 01:22:13 +0200 (Fri, 11 Aug 2006) | 5 lines
Whitespace normalization broke test_cgi, because a line
of quoted test data relied on preserving a single trailing
blank. Changed the string from raw to regular, and forced
in the trailing blank via an explicit \x20 escape.
........
r51198 | tim.peters | 2006-08-11 02:49:01 +0200 (Fri, 11 Aug 2006) | 10 lines
test_PyThreadState_SetAsyncExc(): This is failing on some
64-bit boxes. I have no idea what the ctypes docs mean
by "integers", and blind-guessing here that it intended to
mean the signed C "int" type, in which case perhaps I can
repair this by feeding the thread id argument to type
ctypes.c_long().
Also made the worker thread daemonic, so it doesn't hang
Python shutdown if the test continues to fail.
........
r51199 | tim.peters | 2006-08-11 05:49:10 +0200 (Fri, 11 Aug 2006) | 6 lines
force_test_exit(): This has been completely ineffective
at stopping test_signal from hanging forever on the Tru64
buildbot. That could be because there's no such thing as
signal.SIGALARM. Changed to the idiotic (but standard)
signal.SIGALRM instead, and added some more debug output.
........
r51202 | neal.norwitz | 2006-08-11 08:09:41 +0200 (Fri, 11 Aug 2006) | 6 lines
Fix the failures on cygwin (2006-08-10 fixed the actual locking issue).
The first hunk changes the colon to an ! like other Windows variants.
We need to always wait on the child so the lock gets released and
no other tests fail. This is the try/finally in the second hunk.
........
r51205 | georg.brandl | 2006-08-11 09:15:38 +0200 (Fri, 11 Aug 2006) | 3 lines
Add Chris McDonough (latest cgi.py patch)
........
r51206 | georg.brandl | 2006-08-11 09:26:10 +0200 (Fri, 11 Aug 2006) | 3 lines
logging's atexit hook now runs even if the rest of the module has
already been cleaned up.
........
r51212 | thomas.wouters | 2006-08-11 17:02:39 +0200 (Fri, 11 Aug 2006) | 4 lines
Add ignore of *.pyc and *.pyo to Lib/xml/etree/.
........
r51215 | thomas.heller | 2006-08-11 21:55:35 +0200 (Fri, 11 Aug 2006) | 7 lines
When a ctypes C callback function is called, zero out the result
storage before converting the result to C data. See the comment in
the code for details.
Provide a better context for errors when the conversion of a callback
function's result cannot be converted.
........
r51218 | neal.norwitz | 2006-08-12 03:43:40 +0200 (Sat, 12 Aug 2006) | 6 lines
Klocwork made another run and found a bunch more problems.
This is the first batch of fixes that should be easy to verify based on context.
This fixes problem numbers: 220 (ast), 323-324 (symtable),
321-322 (structseq), 215 (array), 210 (hotshot), 182 (codecs), 209 (etree).
........
r51219 | neal.norwitz | 2006-08-12 03:45:47 +0200 (Sat, 12 Aug 2006) | 9 lines
Even though _Py_Mangle() isn't truly public anyone can call it and
there was no verification that privateobj was a PyString. If it wasn't
a string, this could have allowed a NULL pointer to creep in below and crash.
I wonder if this should be PyString_CheckExact? Must identifiers be strings
or can they be subclasses?
Klocwork #275
........
r51220 | neal.norwitz | 2006-08-12 03:46:42 +0200 (Sat, 12 Aug 2006) | 5 lines
It's highly unlikely, though possible for PyEval_Get*() to return NULLs.
So be safe and do an XINCREF.
Klocwork # 221-222.
........
r51221 | neal.norwitz | 2006-08-12 03:47:59 +0200 (Sat, 12 Aug 2006) | 7 lines
This code is actually not used unless WITHOUT_COMPLEX is defined.
However, there was no error checking that PyFloat_FromDouble returned
a valid pointer. I believe this change is correct as it seemed
to follow other code in the area.
Klocwork # 292.
........
r51222 | neal.norwitz | 2006-08-12 03:49:12 +0200 (Sat, 12 Aug 2006) | 5 lines
Handle NULL nodes while parsing. I'm not entirely sure this is correct.
There might be something else that needs to be done to setup the error.
Klocwork #295.
........
r51223 | neal.norwitz | 2006-08-12 03:50:38 +0200 (Sat, 12 Aug 2006) | 6 lines
If _stat_float_times is false, we will try to INCREF ival which could be NULL.
Return early in that case. The caller checks for PyErr_Occurred so this
should be ok.
Klocwork #297
........
r51224 | neal.norwitz | 2006-08-12 03:51:12 +0200 (Sat, 12 Aug 2006) | 3 lines
Move the assert which checks for a NULL pointer first.
Klocwork #274.
........
r51225 | neal.norwitz | 2006-08-12 03:53:28 +0200 (Sat, 12 Aug 2006) | 5 lines
Try to handle a malloc failure. I'm not entirely sure this is correct.
There might be something else we need to do to handle the exception.
Klocwork # 212-213
........
r51226 | neal.norwitz | 2006-08-12 03:57:47 +0200 (Sat, 12 Aug 2006) | 6 lines
I'm not sure why this code allocates this string for the error message.
I think it would be better to always use snprintf and have the format
limit the size of the name appropriately (like %.200s).
Klocwork #340
........
r51227 | neal.norwitz | 2006-08-12 04:06:34 +0200 (Sat, 12 Aug 2006) | 3 lines
Check returned pointer is valid.
Klocwork #233
........
r51228 | neal.norwitz | 2006-08-12 04:12:30 +0200 (Sat, 12 Aug 2006) | 1 line
Whoops, how did that get in there. :-) Revert all the parts of 51227 that were not supposed to go it. Only Modules/_ctypes/cfields.c was supposed to be changed
........
r51229 | neal.norwitz | 2006-08-12 04:33:36 +0200 (Sat, 12 Aug 2006) | 4 lines
Don't deref v if it's NULL.
Klocwork #214
........
r51230 | neal.norwitz | 2006-08-12 05:16:54 +0200 (Sat, 12 Aug 2006) | 5 lines
Check return of PyMem_MALLOC (garbage) is non-NULL.
Check seq in both portions of if/else.
Klocwork #289-290.
........
r51231 | neal.norwitz | 2006-08-12 05:17:41 +0200 (Sat, 12 Aug 2006) | 4 lines
PyModule_GetDict() can fail, produce fatal errors if this happens on startup.
Klocwork #298-299.
........
r51232 | neal.norwitz | 2006-08-12 05:18:50 +0200 (Sat, 12 Aug 2006) | 5 lines
Verify verdat which is returned from malloc is not NULL.
Ensure we don't pass NULL to free.
Klocwork #306 (at least the first part, checking malloc)
........
r51233 | tim.peters | 2006-08-12 06:42:47 +0200 (Sat, 12 Aug 2006) | 35 lines
test_signal: Signal handling on the Tru64 buildbot
appears to be utterly insane. Plug some theoretical
insecurities in the test script:
- Verify that the SIGALRM handler was actually installed.
- Don't call alarm() before the handler is installed.
- Move everything that can fail inside the try/finally,
so the test cleans up after itself more often.
- Try sending all the expected signals in
force_test_exit(), not just SIGALRM. Since that was
fixed to actually send SIGALRM (instead of invisibly
dying with an AttributeError), we've seen that sending
SIGALRM alone does not stop this from hanging.
- Move the "kill the child" business into the finally
clause, so the child doesn't survive test failure
to send SIGALRM to other tests later (there are also
baffling SIGALRM-related failures in test_socket).
- Cancel the alarm in the finally clause -- if the
test dies early, we again don't want SIGALRM showing
up to confuse a later test.
Alas, this still relies on timing luck wrt the spawned
script that sends the test signals, but it's hard to see
how waiting for seconds can so often be so unlucky.
test_threadedsignals: curiously, this test never fails
on Tru64, but doesn't normally signal SIGALRM. Anyway,
fixed an obvious (but probably inconsequential) logic
error.
........
r51234 | tim.peters | 2006-08-12 07:17:41 +0200 (Sat, 12 Aug 2006) | 8 lines
Ah, fudge. One of the prints here actually "shouldn't be"
protected by "if verbose:", which caused the test to fail on
all non-Windows boxes.
Note that I deliberately didn't convert this to unittest yet,
because I expect it would be even harder to debug this on Tru64
after conversion.
........
r51235 | georg.brandl | 2006-08-12 10:32:02 +0200 (Sat, 12 Aug 2006) | 3 lines
Repair logging test spew caused by rev. 51206.
........
r51236 | neal.norwitz | 2006-08-12 19:03:09 +0200 (Sat, 12 Aug 2006) | 8 lines
Patch #1538606, Patch to fix __index__() clipping.
I modified this patch some by fixing style, some error checking, and adding
XXX comments. This patch requires review and some changes are to be expected.
I'm checking in now to get the greatest possible review and establish a
baseline for moving forward. I don't want this to hold up release if possible.
........
r51238 | neal.norwitz | 2006-08-12 20:44:06 +0200 (Sat, 12 Aug 2006) | 10 lines
Fix a couple of bugs exposed by the new __index__ code. The 64-bit buildbots
were failing due to inappropriate clipping of numbers larger than 2**31
with new-style classes. (typeobject.c) In reviewing the code for classic
classes, there were 2 problems. Any negative value return could be returned.
Always return -1 if there was an error. Also make the checks similar
with the new-style classes. I believe this is correct for 32 and 64 bit
boxes, including Windows64.
Add a test of classic classes too.
........
r51240 | neal.norwitz | 2006-08-13 02:20:49 +0200 (Sun, 13 Aug 2006) | 1 line
SF bug #1539336, distutils example code missing
........
r51245 | neal.norwitz | 2006-08-13 20:10:10 +0200 (Sun, 13 Aug 2006) | 6 lines
Move/copy assert for tstate != NULL before first use.
Verify that PyEval_Get{Globals,Locals} returned valid pointers.
Klocwork 231-232
........
r51246 | neal.norwitz | 2006-08-13 20:10:28 +0200 (Sun, 13 Aug 2006) | 5 lines
Handle a whole lot of failures from PyString_FromInternedString().
Should fix most of Klocwork 234-272.
........
r51247 | neal.norwitz | 2006-08-13 20:10:47 +0200 (Sun, 13 Aug 2006) | 8 lines
cpathname could be NULL if it was longer than MAXPATHLEN. Don't try
to write the .pyc to NULL.
Check results of PyList_GetItem() and PyModule_GetDict() are not NULL.
Klocwork 282, 283, 285
........
r51248 | neal.norwitz | 2006-08-13 20:11:08 +0200 (Sun, 13 Aug 2006) | 6 lines
Fix segfault when doing string formatting on subclasses of long if
__oct__, __hex__ don't return a string.
Klocwork 308
........
r51250 | neal.norwitz | 2006-08-13 20:11:27 +0200 (Sun, 13 Aug 2006) | 5 lines
Check return result of PyModule_GetDict().
Fix a bunch of refleaks in the init of the module. This would only be found
when running python -v.
........
r51251 | neal.norwitz | 2006-08-13 20:11:43 +0200 (Sun, 13 Aug 2006) | 5 lines
Handle malloc and fopen failures more gracefully.
Klocwork 180-181
........
r51252 | neal.norwitz | 2006-08-13 20:12:03 +0200 (Sun, 13 Aug 2006) | 7 lines
It's very unlikely, though possible that source is not a string. Verify
that PyString_AsString() returns a valid pointer. (The problem can
arise when zlib.decompress doesn't return a string.)
Klocwork 346
........
r51253 | neal.norwitz | 2006-08-13 20:12:26 +0200 (Sun, 13 Aug 2006) | 5 lines
Handle failures from lookup.
Klocwork 341-342
........
r51254 | neal.norwitz | 2006-08-13 20:12:45 +0200 (Sun, 13 Aug 2006) | 6 lines
Handle failure from PyModule_GetDict() (Klocwork 208).
Fix a bunch of refleaks in the init of the module. This would only be found
when running python -v.
........
r51255 | neal.norwitz | 2006-08-13 20:13:02 +0200 (Sun, 13 Aug 2006) | 4 lines
Really address the issue of where to place the assert for leftblock.
(Followup of Klocwork 274)
........
r51256 | neal.norwitz | 2006-08-13 20:13:36 +0200 (Sun, 13 Aug 2006) | 4 lines
Handle malloc failure.
Klocwork 281
........
r51258 | neal.norwitz | 2006-08-13 20:40:39 +0200 (Sun, 13 Aug 2006) | 4 lines
Handle alloca failures.
Klocwork 225-228
........
r51259 | neal.norwitz | 2006-08-13 20:41:15 +0200 (Sun, 13 Aug 2006) | 1 line
Get rid of compiler warning
........
r51261 | neal.norwitz | 2006-08-14 02:51:15 +0200 (Mon, 14 Aug 2006) | 1 line
Ignore pgen.exe and kill_python.exe for cygwin
........
r51262 | neal.norwitz | 2006-08-14 02:59:03 +0200 (Mon, 14 Aug 2006) | 4 lines
Can't return NULL from a void function. If there is a memory error,
about the best we can do is call PyErr_WriteUnraisable and go on.
We won't be able to do the call below either, so verify delstr is valid.
........
r51263 | neal.norwitz | 2006-08-14 03:49:54 +0200 (Mon, 14 Aug 2006) | 1 line
Update purify doc some.
........
r51264 | thomas.heller | 2006-08-14 09:13:05 +0200 (Mon, 14 Aug 2006) | 2 lines
Remove unused, buggy test function.
Fixes klockwork issue #207.
........
r51265 | thomas.heller | 2006-08-14 09:14:09 +0200 (Mon, 14 Aug 2006) | 2 lines
Check for NULL return value from new_CArgObject().
Fixes klockwork issues #183, #184, #185.
........
r51266 | thomas.heller | 2006-08-14 09:50:14 +0200 (Mon, 14 Aug 2006) | 2 lines
Check for NULL return value of GenericCData_new().
Fixes klockwork issues #188, #189.
........
r51274 | thomas.heller | 2006-08-14 12:02:24 +0200 (Mon, 14 Aug 2006) | 2 lines
Revert the change that tries to zero out a closure's result storage
area because the size if unknown in source/callproc.c.
........
r51276 | marc-andre.lemburg | 2006-08-14 12:55:19 +0200 (Mon, 14 Aug 2006) | 11 lines
Slightly revised version of patch #1538956:
Replace UnicodeDecodeErrors raised during == and !=
compares of Unicode and other objects with a new
UnicodeWarning.
All other comparisons continue to raise exceptions.
Exceptions other than UnicodeDecodeErrors are also left
untouched.
........
r51277 | thomas.heller | 2006-08-14 13:17:48 +0200 (Mon, 14 Aug 2006) | 13 lines
Apply the patch #1532975 plus ideas from the patch #1533481.
ctypes instances no longer have the internal and undocumented
'_as_parameter_' attribute which was used to adapt them to foreign
function calls; this mechanism is replaced by a function pointer in
the type's stgdict.
In the 'from_param' class methods, try the _as_parameter_ attribute if
other conversions are not possible.
This makes the documented _as_parameter_ mechanism work as intended.
Change the ctypes version number to 1.0.1.
........
r51278 | marc-andre.lemburg | 2006-08-14 13:44:34 +0200 (Mon, 14 Aug 2006) | 3 lines
Readd NEWS items that were accidentally removed by r51276.
........
r51279 | georg.brandl | 2006-08-14 14:36:06 +0200 (Mon, 14 Aug 2006) | 3 lines
Improve markup in PyUnicode_RichCompare.
........
r51280 | marc-andre.lemburg | 2006-08-14 14:57:27 +0200 (Mon, 14 Aug 2006) | 3 lines
Correct an accidentally removed previous patch.
........
r51281 | thomas.heller | 2006-08-14 18:17:41 +0200 (Mon, 14 Aug 2006) | 3 lines
Patch #1536908: Add support for AMD64 / OpenBSD.
Remove the -no-stack-protector compiler flag for OpenBSD
as it has been reported to be unneeded.
........
r51282 | thomas.heller | 2006-08-14 18:20:04 +0200 (Mon, 14 Aug 2006) | 1 line
News item for rev 51281.
........
r51283 | georg.brandl | 2006-08-14 22:25:39 +0200 (Mon, 14 Aug 2006) | 3 lines
Fix refleak introduced in rev. 51248.
........
r51284 | georg.brandl | 2006-08-14 23:34:08 +0200 (Mon, 14 Aug 2006) | 5 lines
Make tabnanny recognize IndentationErrors raised by tokenize.
Add a test to test_inspect to make sure indented source
is recognized correctly. (fixes #1224621)
........
r51285 | georg.brandl | 2006-08-14 23:42:55 +0200 (Mon, 14 Aug 2006) | 3 lines
Patch #1535500: fix segfault in BZ2File.writelines and make sure it
raises the correct exceptions.
........
r51287 | georg.brandl | 2006-08-14 23:45:32 +0200 (Mon, 14 Aug 2006) | 3 lines
Add an additional test: BZ2File write methods should raise IOError
when file is read-only.
........
r51289 | georg.brandl | 2006-08-14 23:55:28 +0200 (Mon, 14 Aug 2006) | 3 lines
Patch #1536071: trace.py should now find the full module name of a
file correctly even on Windows.
........
r51290 | georg.brandl | 2006-08-15 00:01:24 +0200 (Tue, 15 Aug 2006) | 3 lines
Cookie.py shouldn't "bogusly" use string._idmap.
........
r51291 | georg.brandl | 2006-08-15 00:10:24 +0200 (Tue, 15 Aug 2006) | 3 lines
Patch #1511317: don't crash on invalid hostname info
........
r51292 | tim.peters | 2006-08-15 02:25:04 +0200 (Tue, 15 Aug 2006) | 2 lines
Whitespace normalization.
........
r51293 | neal.norwitz | 2006-08-15 06:14:57 +0200 (Tue, 15 Aug 2006) | 3 lines
Georg fixed one of my bugs, so I'll repay him with 2 NEWS entries.
Now we're even. :-)
........
r51295 | neal.norwitz | 2006-08-15 06:58:28 +0200 (Tue, 15 Aug 2006) | 8 lines
Fix the test for SocketServer so it should pass on cygwin and not fail
sporadically on other platforms. This is really a band-aid that doesn't
fix the underlying issue in SocketServer. It's not clear if it's worth
it to fix SocketServer, however, I opened a bug to track it:
http://python.org/sf/1540386
........
r51296 | neal.norwitz | 2006-08-15 06:59:30 +0200 (Tue, 15 Aug 2006) | 3 lines
Update the docstring to use a version a little newer than 1999. This was
taken from a Debian patch. Should we update the version for each release?
........
r51298 | neal.norwitz | 2006-08-15 08:29:03 +0200 (Tue, 15 Aug 2006) | 2 lines
Subclasses of int/long are allowed to define an __index__.
........
r51300 | thomas.heller | 2006-08-15 15:07:21 +0200 (Tue, 15 Aug 2006) | 1 line
Check for NULL return value from new_CArgObject calls.
........
r51303 | kurt.kaiser | 2006-08-16 05:15:26 +0200 (Wed, 16 Aug 2006) | 2 lines
The 'with' statement is now a Code Context block opener
........
r51304 | anthony.baxter | 2006-08-16 05:42:26 +0200 (Wed, 16 Aug 2006) | 1 line
preparing for 2.5c1
........
r51305 | anthony.baxter | 2006-08-16 05:58:37 +0200 (Wed, 16 Aug 2006) | 1 line
preparing for 2.5c1 - no, really this time
........
r51306 | kurt.kaiser | 2006-08-16 07:01:42 +0200 (Wed, 16 Aug 2006) | 9 lines
Patch #1540892: site.py Quitter() class attempts to close sys.stdin
before raising SystemExit, allowing IDLE to honor quit() and exit().
M Lib/site.py
M Lib/idlelib/PyShell.py
M Lib/idlelib/CREDITS.txt
M Lib/idlelib/NEWS.txt
M Misc/NEWS
........
r51307 | ka-ping.yee | 2006-08-16 09:02:50 +0200 (Wed, 16 Aug 2006) | 6 lines
Update code and tests to support the 'bytes_le' attribute (for
little-endian byte order on Windows), and to work around clocks
with low resolution yielding duplicate UUIDs.
Anthony Baxter has approved this change.
........
r51308 | kurt.kaiser | 2006-08-16 09:04:17 +0200 (Wed, 16 Aug 2006) | 2 lines
Get quit() and exit() to work cleanly when not using subprocess.
........
r51309 | marc-andre.lemburg | 2006-08-16 10:13:26 +0200 (Wed, 16 Aug 2006) | 2 lines
Revert to having static version numbers again.
........
r51310 | martin.v.loewis | 2006-08-16 14:55:10 +0200 (Wed, 16 Aug 2006) | 2 lines
Build _hashlib on Windows. Build OpenSSL with masm assembler code.
Fixes #1535502.
........
r51311 | thomas.heller | 2006-08-16 15:03:11 +0200 (Wed, 16 Aug 2006) | 6 lines
Add commented assert statements to check that the result of
PyObject_stgdict() and PyType_stgdict() calls are non-NULL before
dereferencing the result. Hopefully this fixes what klocwork is
complaining about.
Fix a few other nits as well.
........
r51312 | anthony.baxter | 2006-08-16 15:08:25 +0200 (Wed, 16 Aug 2006) | 1 line
news entry for 51307
........
r51313 | andrew.kuchling | 2006-08-16 15:22:20 +0200 (Wed, 16 Aug 2006) | 1 line
Add UnicodeWarning
........
r51314 | andrew.kuchling | 2006-08-16 15:41:52 +0200 (Wed, 16 Aug 2006) | 1 line
Bump document version to 1.0; remove pystone paragraph
........
r51315 | andrew.kuchling | 2006-08-16 15:51:32 +0200 (Wed, 16 Aug 2006) | 1 line
Link to docs; remove an XXX comment
........
r51316 | martin.v.loewis | 2006-08-16 15:58:51 +0200 (Wed, 16 Aug 2006) | 1 line
Make cl build step compile-only (/c). Remove libs from source list.
........
r51317 | thomas.heller | 2006-08-16 16:07:44 +0200 (Wed, 16 Aug 2006) | 5 lines
The __repr__ method of a NULL py_object does no longer raise an
exception. Remove a stray '?' character from the exception text
when the value is retrieved of such an object.
Includes tests.
........
r51318 | andrew.kuchling | 2006-08-16 16:18:23 +0200 (Wed, 16 Aug 2006) | 1 line
Update bug/patch counts
........
r51319 | andrew.kuchling | 2006-08-16 16:21:14 +0200 (Wed, 16 Aug 2006) | 1 line
Wording/typo fixes
........
r51320 | thomas.heller | 2006-08-16 17:10:12 +0200 (Wed, 16 Aug 2006) | 9 lines
Remove the special casing of Py_None when converting the return value
of the Python part of a callback function to C. If it cannot be
converted, call PyErr_WriteUnraisable with the exception we got.
Before, arbitrary data has been passed to the calling C code in this
case.
(I'm not really sure the NEWS entry is understandable, but I cannot
find better words)
........
r51321 | marc-andre.lemburg | 2006-08-16 18:11:01 +0200 (Wed, 16 Aug 2006) | 2 lines
Add NEWS item mentioning the reverted distutils version number patch.
........
r51322 | fredrik.lundh | 2006-08-16 18:47:07 +0200 (Wed, 16 Aug 2006) | 5 lines
SF#1534630
ignore data that arrives before the opening start tag
........
r51324 | andrew.kuchling | 2006-08-16 19:11:18 +0200 (Wed, 16 Aug 2006) | 1 line
Grammar fix
........
r51328 | thomas.heller | 2006-08-16 20:02:11 +0200 (Wed, 16 Aug 2006) | 12 lines
Tutorial:
Clarify somewhat how parameters are passed to functions
(especially explain what integer means).
Correct the table - Python integers and longs can both be used.
Further clarification to the table comparing ctypes types, Python
types, and C types.
Reference:
Replace integer by C ``int`` where it makes sense.
........
r51329 | kurt.kaiser | 2006-08-16 23:45:59 +0200 (Wed, 16 Aug 2006) | 8 lines
File menu hotkeys: there were three 'p' assignments. Reassign the
'Save Copy As' and 'Print' hotkeys to 'y' and 't'. Change the
Shell menu hotkey from 's' to 'l'.
M Bindings.py
M PyShell.py
M NEWS.txt
........
r51330 | neil.schemenauer | 2006-08-17 01:38:05 +0200 (Thu, 17 Aug 2006) | 3 lines
Fix a bug in the ``compiler`` package that caused invalid code to be
generated for generator expressions.
........
r51342 | martin.v.loewis | 2006-08-17 21:19:32 +0200 (Thu, 17 Aug 2006) | 3 lines
Merge 51340 and 51341 from 2.5 branch:
Leave tk build directory to restore original path.
Invoke debug mk1mf.pl after running Configure.
........
r51354 | martin.v.loewis | 2006-08-18 05:47:18 +0200 (Fri, 18 Aug 2006) | 3 lines
Bug #1541863: uuid.uuid1 failed to generate unique identifiers
on systems with low clock resolution.
........
r51355 | neal.norwitz | 2006-08-18 05:57:54 +0200 (Fri, 18 Aug 2006) | 1 line
Add template for 2.6 on HEAD
........
r51356 | neal.norwitz | 2006-08-18 06:01:38 +0200 (Fri, 18 Aug 2006) | 1 line
More post-release wibble
........
r51357 | neal.norwitz | 2006-08-18 06:58:33 +0200 (Fri, 18 Aug 2006) | 1 line
Try to get Windows bots working again
........
r51358 | neal.norwitz | 2006-08-18 07:10:00 +0200 (Fri, 18 Aug 2006) | 1 line
Try to get Windows bots working again. Take 2
........
r51359 | neal.norwitz | 2006-08-18 07:39:20 +0200 (Fri, 18 Aug 2006) | 1 line
Try to get Unix bots install working again.
........
r51360 | neal.norwitz | 2006-08-18 07:41:46 +0200 (Fri, 18 Aug 2006) | 1 line
Set version to 2.6a0, seems more consistent.
........
r51362 | neal.norwitz | 2006-08-18 08:14:52 +0200 (Fri, 18 Aug 2006) | 1 line
More version wibble
........
r51364 | georg.brandl | 2006-08-18 09:27:59 +0200 (Fri, 18 Aug 2006) | 4 lines
Bug #1541682: Fix example in the "Refcount details" API docs.
Additionally, remove a faulty example showing PySequence_SetItem applied
to a newly created list object and add notes that this isn't a good idea.
........
r51366 | anthony.baxter | 2006-08-18 09:29:02 +0200 (Fri, 18 Aug 2006) | 3 lines
Updating IDLE's version number to match Python's (as per python-dev
discussion).
........
r51367 | anthony.baxter | 2006-08-18 09:30:07 +0200 (Fri, 18 Aug 2006) | 1 line
RPM specfile updates
........
r51368 | georg.brandl | 2006-08-18 09:35:47 +0200 (Fri, 18 Aug 2006) | 2 lines
Typo in tp_clear docs.
........
r51378 | andrew.kuchling | 2006-08-18 15:57:13 +0200 (Fri, 18 Aug 2006) | 1 line
Minor edits
........
r51379 | thomas.heller | 2006-08-18 16:38:46 +0200 (Fri, 18 Aug 2006) | 6 lines
Add asserts to check for 'impossible' NULL values, with comments.
In one place where I'n not 1000% sure about the non-NULL, raise
a RuntimeError for safety.
This should fix the klocwork issues that Neal sent me. If so,
it should be applied to the release25-maint branch also.
........
r51400 | neal.norwitz | 2006-08-19 06:22:33 +0200 (Sat, 19 Aug 2006) | 5 lines
Move initialization of interned strings to before allocating the
object so we don't leak op. (Fixes an earlier patch to this code)
Klockwork #350
........
r51401 | neal.norwitz | 2006-08-19 06:23:04 +0200 (Sat, 19 Aug 2006) | 4 lines
Move assert to after NULL check, otherwise we deref NULL in the assert.
Klocwork #307
........
r51402 | neal.norwitz | 2006-08-19 06:25:29 +0200 (Sat, 19 Aug 2006) | 2 lines
SF #1542693: Remove semi-colon at end of PyImport_ImportModuleEx macro
........
r51403 | neal.norwitz | 2006-08-19 06:28:55 +0200 (Sat, 19 Aug 2006) | 6 lines
Move initialization to after the asserts for non-NULL values.
Klocwork 286-287.
(I'm not backporting this, but if someone wants to, feel free.)
........
r51404 | neal.norwitz | 2006-08-19 06:52:03 +0200 (Sat, 19 Aug 2006) | 6 lines
Handle PyString_FromInternedString() failing (unlikely, but possible).
Klocwork #325
(I'm not backporting this, but if someone wants to, feel free.)
........
r51416 | georg.brandl | 2006-08-20 15:15:39 +0200 (Sun, 20 Aug 2006) | 2 lines
Patch #1542948: fix urllib2 header casing issue. With new test.
........
r51428 | jeremy.hylton | 2006-08-21 18:19:37 +0200 (Mon, 21 Aug 2006) | 3 lines
Move peephole optimizer to separate file.
........
r51429 | jeremy.hylton | 2006-08-21 18:20:29 +0200 (Mon, 21 Aug 2006) | 2 lines
Move peephole optimizer to separate file. (Forgot .h in previous checkin.)
........
r51432 | neal.norwitz | 2006-08-21 19:59:46 +0200 (Mon, 21 Aug 2006) | 5 lines
Fix bug #1543303, tarfile adds padding that breaks gunzip.
Patch # 1543897.
Will backport to 2.5
........
r51433 | neal.norwitz | 2006-08-21 20:01:30 +0200 (Mon, 21 Aug 2006) | 2 lines
Add assert to make Klocwork happy (#276)
........
2006-08-21 16:07:27 -03:00
|
|
|
del logging._handlerList[:]
|
2006-01-16 17:28:37 -04:00
|
|
|
# Handlers add themselves to logging._handlers
|
|
|
|
handlers = _install_handlers(cp, formatters)
|
Merged revisions 64365,64370,64406,64408-64409,64412,64416-64417,64420-64421,64425-64428 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r64365 | raymond.hettinger | 2008-06-17 19:56:57 -0500 (Tue, 17 Jun 2008) | 1 line
Fix double decref.
........
r64370 | mark.dickinson | 2008-06-18 04:20:17 -0500 (Wed, 18 Jun 2008) | 2 lines
Typo fix
........
r64406 | andrew.kuchling | 2008-06-19 09:02:30 -0500 (Thu, 19 Jun 2008) | 1 line
Only include update_lines_cols() function when it's actually going to be used
........
r64408 | amaury.forgeotdarc | 2008-06-19 14:57:39 -0500 (Thu, 19 Jun 2008) | 2 lines
test_macos can be skipped on non-mac platforms.
........
r64409 | andrew.kuchling | 2008-06-19 15:33:31 -0500 (Thu, 19 Jun 2008) | 1 line
Put threading in front of thread
........
r64412 | amaury.forgeotdarc | 2008-06-19 16:17:12 -0500 (Thu, 19 Jun 2008) | 3 lines
In test_site, correctly escape backslashes in path names.
This allows the test to pass when the username begins with a lowercase 't'...
........
r64416 | vinay.sajip | 2008-06-19 17:40:17 -0500 (Thu, 19 Jun 2008) | 2 lines
Bug #3136: fileConfig()'s disabling of old loggers is now conditional via an optional disable_existing_loggers parameter, but the default value is such that the old behaviour is preserved.
Thanks to Leandro Lucarella for the patch.
........
r64417 | vinay.sajip | 2008-06-19 17:41:08 -0500 (Thu, 19 Jun 2008) | 1 line
Updated with fix for #3136.
........
r64420 | andrew.kuchling | 2008-06-19 21:05:57 -0500 (Thu, 19 Jun 2008) | 1 line
Various items
........
r64421 | andrew.kuchling | 2008-06-19 21:11:42 -0500 (Thu, 19 Jun 2008) | 1 line
Fix comment typos
........
r64425 | andrew.kuchling | 2008-06-20 06:39:54 -0500 (Fri, 20 Jun 2008) | 1 line
Various items
........
r64426 | mark.dickinson | 2008-06-20 09:53:43 -0500 (Fri, 20 Jun 2008) | 4 lines
Issue #3004: Minor fix to slice.indices(). slice(-10).indices(9) now
returns (0, 0, 1) instead of (0, -1, 1), and slice(None, 10, -1).indices(10)
returns (9, 9, -1) instead of (9, 10, -1).
........
r64427 | mark.dickinson | 2008-06-20 10:17:41 -0500 (Fri, 20 Jun 2008) | 2 lines
Fix outdated count of the number of new math module functions.
........
r64428 | mark.dickinson | 2008-06-20 10:26:19 -0500 (Fri, 20 Jun 2008) | 2 lines
Fix another typo in math_sum comment
........
2008-07-02 13:11:42 -03:00
|
|
|
_install_loggers(cp, handlers, disable_existing_loggers)
|
2002-11-13 12:15:58 -04:00
|
|
|
finally:
|
|
|
|
logging._releaseLock()
|
|
|
|
|
2006-01-16 17:28:37 -04:00
|
|
|
|
2006-01-20 14:28:03 -04:00
|
|
|
def _resolve(name):
|
|
|
|
"""Resolve a dotted name to a global object."""
|
2007-04-17 05:48:32 -03:00
|
|
|
name = name.split('.')
|
2006-01-20 14:28:03 -04:00
|
|
|
used = name.pop(0)
|
|
|
|
found = __import__(used)
|
|
|
|
for n in name:
|
|
|
|
used = used + '.' + n
|
|
|
|
try:
|
|
|
|
found = getattr(found, n)
|
|
|
|
except AttributeError:
|
|
|
|
__import__(used)
|
|
|
|
found = getattr(found, n)
|
|
|
|
return found
|
|
|
|
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
def _strip_spaces(alist):
|
|
|
|
return map(lambda x: x.strip(), alist)
|
2006-01-20 14:28:03 -04:00
|
|
|
|
2006-01-16 17:28:37 -04:00
|
|
|
def _create_formatters(cp):
|
|
|
|
"""Create and return formatters"""
|
2010-11-10 14:57:39 -04:00
|
|
|
flist = cp["formatters"]["keys"]
|
2006-01-16 17:28:37 -04:00
|
|
|
if not len(flist):
|
|
|
|
return {}
|
2007-04-17 05:48:32 -03:00
|
|
|
flist = flist.split(",")
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
flist = _strip_spaces(flist)
|
2006-01-16 17:28:37 -04:00
|
|
|
formatters = {}
|
|
|
|
for form in flist:
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
sectname = "formatter_%s" % form
|
2010-11-10 14:57:39 -04:00
|
|
|
fs = cp.get(sectname, "format", raw=True, fallback=None)
|
|
|
|
dfs = cp.get(sectname, "datefmt", raw=True, fallback=None)
|
2006-01-20 14:28:03 -04:00
|
|
|
c = logging.Formatter
|
2010-11-10 14:57:39 -04:00
|
|
|
class_name = cp[sectname].get("class")
|
|
|
|
if class_name:
|
|
|
|
c = _resolve(class_name)
|
2006-01-20 14:28:03 -04:00
|
|
|
f = c(fs, dfs)
|
2006-01-16 17:28:37 -04:00
|
|
|
formatters[form] = f
|
|
|
|
return formatters
|
|
|
|
|
|
|
|
|
|
|
|
def _install_handlers(cp, formatters):
|
|
|
|
"""Install and return handlers"""
|
2010-11-10 14:57:39 -04:00
|
|
|
hlist = cp["handlers"]["keys"]
|
2006-01-16 17:28:37 -04:00
|
|
|
if not len(hlist):
|
|
|
|
return {}
|
2007-04-17 05:48:32 -03:00
|
|
|
hlist = hlist.split(",")
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
hlist = _strip_spaces(hlist)
|
2006-01-16 17:28:37 -04:00
|
|
|
handlers = {}
|
|
|
|
fixups = [] #for inter-handler references
|
|
|
|
for hand in hlist:
|
2010-11-10 14:57:39 -04:00
|
|
|
section = cp["handler_%s" % hand]
|
|
|
|
klass = section["class"]
|
|
|
|
fmt = section.get("formatter", "")
|
Merged revisions 65012,65035,65037-65040,65048,65057,65077,65091-65095,65097-65099,65127-65128,65131,65133-65136,65139,65149-65151,65155,65158-65159,65176-65178,65183-65184,65187-65190,65192,65194 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r65012 | jesse.noller | 2008-07-16 15:24:06 +0200 (Wed, 16 Jul 2008) | 2 lines
Apply patch for issue 3090: ARCHFLAGS parsing incorrect
........
r65035 | georg.brandl | 2008-07-16 23:19:28 +0200 (Wed, 16 Jul 2008) | 2 lines
#3045: fix pydoc behavior for TEMP path with spaces.
........
r65037 | georg.brandl | 2008-07-16 23:31:41 +0200 (Wed, 16 Jul 2008) | 2 lines
#1608818: errno can get set by every call to readdir().
........
r65038 | georg.brandl | 2008-07-17 00:04:20 +0200 (Thu, 17 Jul 2008) | 2 lines
#3305: self->stream can be NULL.
........
r65039 | georg.brandl | 2008-07-17 00:09:17 +0200 (Thu, 17 Jul 2008) | 2 lines
#3345: fix docstring.
........
r65040 | georg.brandl | 2008-07-17 00:33:18 +0200 (Thu, 17 Jul 2008) | 2 lines
#3312: fix two sqlite3 crashes.
........
r65048 | georg.brandl | 2008-07-17 01:35:54 +0200 (Thu, 17 Jul 2008) | 2 lines
#3388: add a paragraph about using "with" for file objects.
........
r65057 | gregory.p.smith | 2008-07-17 05:13:05 +0200 (Thu, 17 Jul 2008) | 2 lines
news note for r63052
........
r65077 | jesse.noller | 2008-07-17 23:01:05 +0200 (Thu, 17 Jul 2008) | 3 lines
Fix issue 3395, update _debugInfo to be _debug_info
........
r65091 | ronald.oussoren | 2008-07-18 07:48:03 +0200 (Fri, 18 Jul 2008) | 2 lines
Last bit of a fix for issue3381 (addon for my patch in r65061)
........
r65092 | vinay.sajip | 2008-07-18 10:59:06 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65093 | vinay.sajip | 2008-07-18 11:00:00 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65094 | vinay.sajip | 2008-07-18 11:00:35 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65095 | vinay.sajip | 2008-07-18 11:01:10 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65097 | georg.brandl | 2008-07-18 12:20:59 +0200 (Fri, 18 Jul 2008) | 2 lines
Remove duplicate entry in __all__.
........
r65098 | georg.brandl | 2008-07-18 12:29:30 +0200 (Fri, 18 Jul 2008) | 2 lines
Correct attribute name.
........
r65099 | georg.brandl | 2008-07-18 13:15:06 +0200 (Fri, 18 Jul 2008) | 3 lines
Document the different meaning of precision for {:f} and {:g}.
Also document how inf and nan are formatted. #3404.
........
r65127 | raymond.hettinger | 2008-07-19 02:42:03 +0200 (Sat, 19 Jul 2008) | 1 line
Improve accuracy of gamma test function
........
r65128 | raymond.hettinger | 2008-07-19 02:43:00 +0200 (Sat, 19 Jul 2008) | 1 line
Add recipe to the itertools docs.
........
r65131 | georg.brandl | 2008-07-19 12:08:55 +0200 (Sat, 19 Jul 2008) | 2 lines
#3378: in case of no memory, don't leak even more memory. :)
........
r65133 | georg.brandl | 2008-07-19 14:39:10 +0200 (Sat, 19 Jul 2008) | 3 lines
#3302: fix segfaults when passing None for arguments that can't
be NULL for the C functions.
........
r65134 | georg.brandl | 2008-07-19 14:46:12 +0200 (Sat, 19 Jul 2008) | 2 lines
#3303: fix crash with invalid Py_DECREF in strcoll().
........
r65135 | georg.brandl | 2008-07-19 15:00:22 +0200 (Sat, 19 Jul 2008) | 3 lines
#3319: don't raise ZeroDivisionError if number of rounds is so
low that benchtime is zero.
........
r65136 | georg.brandl | 2008-07-19 15:09:42 +0200 (Sat, 19 Jul 2008) | 3 lines
#3323: mention that if inheriting from a class without __slots__,
the subclass will have a __dict__ available too.
........
r65139 | georg.brandl | 2008-07-19 15:48:44 +0200 (Sat, 19 Jul 2008) | 2 lines
Add ordering info for findall and finditer.
........
r65149 | raymond.hettinger | 2008-07-20 01:21:57 +0200 (Sun, 20 Jul 2008) | 1 line
Fix compress() recipe in docs to use itertools.
........
r65150 | raymond.hettinger | 2008-07-20 01:58:47 +0200 (Sun, 20 Jul 2008) | 1 line
Clean-up itertools docs and recipes.
........
r65151 | gregory.p.smith | 2008-07-20 02:22:08 +0200 (Sun, 20 Jul 2008) | 9 lines
fix issue3120 - don't truncate handles on 64-bit Windows.
This is still messy, realistically PC/_subprocess.c should never cast pointers
to python numbers and back at all.
I don't have a 64-bit windows build environment because microsoft apparently
thinks that should cost money. Time to watch the buildbots. It builds and
passes tests on 32-bit windows.
........
r65155 | georg.brandl | 2008-07-20 13:50:29 +0200 (Sun, 20 Jul 2008) | 2 lines
#926501: add info where to put the docstring.
........
r65158 | neal.norwitz | 2008-07-20 21:35:23 +0200 (Sun, 20 Jul 2008) | 1 line
Fix a couple of names in error messages that were wrong
........
r65159 | neal.norwitz | 2008-07-20 22:39:36 +0200 (Sun, 20 Jul 2008) | 1 line
Fix misspeeld method name (negative)
........
r65176 | amaury.forgeotdarc | 2008-07-21 23:36:24 +0200 (Mon, 21 Jul 2008) | 4 lines
Increment version number in NEWS file, and move items that were added after 2.6b2.
(I thought there was a script to automate this kind of updates)
........
r65177 | amaury.forgeotdarc | 2008-07-22 00:00:38 +0200 (Tue, 22 Jul 2008) | 5 lines
Issue2378: pdb would delete free variables when stepping into a class statement.
The problem was introduced by r53954, the correction is to restore the symmetry between
PyFrame_FastToLocals and PyFrame_LocalsToFast
........
r65178 | benjamin.peterson | 2008-07-22 00:05:34 +0200 (Tue, 22 Jul 2008) | 1 line
don't use assert statement
........
r65183 | ronald.oussoren | 2008-07-22 09:06:00 +0200 (Tue, 22 Jul 2008) | 2 lines
Fix buglet in fix for issue3381
........
r65184 | ronald.oussoren | 2008-07-22 09:06:33 +0200 (Tue, 22 Jul 2008) | 2 lines
Fix build issue on OSX 10.4, somehow this wasn't committed before.
........
r65187 | raymond.hettinger | 2008-07-22 20:54:02 +0200 (Tue, 22 Jul 2008) | 1 line
Remove out-of-date section on Exact/Inexact.
........
r65188 | raymond.hettinger | 2008-07-22 21:00:47 +0200 (Tue, 22 Jul 2008) | 1 line
Tuples now have both count() and index().
........
r65189 | raymond.hettinger | 2008-07-22 21:03:05 +0200 (Tue, 22 Jul 2008) | 1 line
Fix credits for math.sum()
........
r65190 | raymond.hettinger | 2008-07-22 21:18:50 +0200 (Tue, 22 Jul 2008) | 1 line
One more attribution.
........
r65192 | benjamin.peterson | 2008-07-23 01:44:37 +0200 (Wed, 23 Jul 2008) | 1 line
remove unneeded import
........
r65194 | benjamin.peterson | 2008-07-23 15:25:06 +0200 (Wed, 23 Jul 2008) | 1 line
use isinstance
........
2008-07-23 13:10:53 -03:00
|
|
|
try:
|
|
|
|
klass = eval(klass, vars(logging))
|
|
|
|
except (AttributeError, NameError):
|
|
|
|
klass = _resolve(klass)
|
2010-11-10 14:57:39 -04:00
|
|
|
args = section["args"]
|
2006-01-16 17:28:37 -04:00
|
|
|
args = eval(args, vars(logging))
|
2006-03-17 04:00:19 -04:00
|
|
|
h = klass(*args)
|
2010-11-10 14:57:39 -04:00
|
|
|
if "level" in section:
|
|
|
|
level = section["level"]
|
2006-01-16 17:28:37 -04:00
|
|
|
h.setLevel(logging._levelNames[level])
|
|
|
|
if len(fmt):
|
|
|
|
h.setFormatter(formatters[fmt])
|
Merged revisions 64475,64544-64545,64550,64557-64558,64565,64570,64577,64582-64583,64585,64590,64592-64593,64625,64630,64638,64647,64655-64656,64663-64664 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r64475 | raymond.hettinger | 2008-06-22 22:29:28 -0500 (Sun, 22 Jun 2008) | 1 line
Issue 3161: Missing import and test.
........
r64544 | georg.brandl | 2008-06-26 16:12:55 -0500 (Thu, 26 Jun 2008) | 2 lines
Use newer versions of externals.
........
r64545 | benjamin.peterson | 2008-06-26 16:23:30 -0500 (Thu, 26 Jun 2008) | 1 line
add a htmlview directive
........
r64550 | brett.cannon | 2008-06-26 19:32:16 -0500 (Thu, 26 Jun 2008) | 2 lines
Ignore .pyc and .pyo files.
........
r64557 | mark.dickinson | 2008-06-27 05:11:52 -0500 (Fri, 27 Jun 2008) | 3 lines
Remove trailing 'L's from numerator and denominator in the
repr() of a Fraction instance.
........
r64558 | mark.dickinson | 2008-06-27 06:03:21 -0500 (Fri, 27 Jun 2008) | 2 lines
Add Jean Brouwers for his work on math.sum
........
r64565 | raymond.hettinger | 2008-06-27 16:34:24 -0500 (Fri, 27 Jun 2008) | 1 line
Fix whitespace in example code.
........
r64570 | hyeshik.chang | 2008-06-27 20:04:31 -0500 (Fri, 27 Jun 2008) | 8 lines
Give information for compililation of _multiprocessing.SemLock on FreeBSD:
FreeBSD's P1003.1b semaphore support is highly experimental and
it's disabled by default. Even if a user loads the experimental
kernel module manually, _multiprocessing doesn't work correctly due
to several known incompatibilities around sem_unlink and sem_getvalue,
yet.
........
r64577 | raymond.hettinger | 2008-06-28 17:16:53 -0500 (Sat, 28 Jun 2008) | 1 line
Issue 3230: Do not the set specific size macro.
........
r64582 | benjamin.peterson | 2008-06-28 18:06:05 -0500 (Sat, 28 Jun 2008) | 2 lines
convert test_audioop to unittest. Thanks to Giampaolo Rodola.
........
r64583 | benjamin.peterson | 2008-06-28 18:06:49 -0500 (Sat, 28 Jun 2008) | 1 line
rewrap
........
r64585 | benjamin.peterson | 2008-06-28 18:35:31 -0500 (Sat, 28 Jun 2008) | 1 line
fix typo
........
r64590 | benjamin.peterson | 2008-06-29 08:43:07 -0500 (Sun, 29 Jun 2008) | 1 line
reinstate the ending backtick. thanks Nick :)
........
r64592 | vinay.sajip | 2008-06-29 16:25:28 -0500 (Sun, 29 Jun 2008) | 2 lines
Removed out-of-date comment in _install_handlers and
used issubclass in place of equality comparison of classes.
........
r64593 | vinay.sajip | 2008-06-29 16:27:15 -0500 (Sun, 29 Jun 2008) | 1 line
Updated to reflect change in logging.config to remove out-of-date comment in _install_handlers and the use of issubclass in place of equality comparison of classes.
........
r64625 | georg.brandl | 2008-07-01 14:59:00 -0500 (Tue, 01 Jul 2008) | 2 lines
Add a link to PEP 324.
........
r64630 | georg.brandl | 2008-07-01 15:18:10 -0500 (Tue, 01 Jul 2008) | 2 lines
#3216: fix Execute's parameter description.
........
r64638 | georg.brandl | 2008-07-01 15:50:02 -0500 (Tue, 01 Jul 2008) | 2 lines
#1410739: add a footnote about "is" and "unusual" behavior.
........
r64647 | benjamin.peterson | 2008-07-01 18:33:06 -0500 (Tue, 01 Jul 2008) | 1 line
add ABC to the glossary
........
r64655 | mark.dickinson | 2008-07-02 04:37:01 -0500 (Wed, 02 Jul 2008) | 7 lines
Replace occurrences of '\d' with '[0-9]' in Decimal regex, to make sure
that the behaviour of Decimal doesn't change if/when re.UNICODE becomes
assumed in Python 3.0.
Also add a check that alternative Unicode digits (e.g. u'\N{FULLWIDTH
DIGIT ONE}') are *not* accepted in a numeric string.
........
r64656 | nick.coghlan | 2008-07-02 08:09:19 -0500 (Wed, 02 Jul 2008) | 1 line
Issue 3190: pydoc now hides module __package__ attributes
........
r64663 | jesse.noller | 2008-07-02 11:44:09 -0500 (Wed, 02 Jul 2008) | 1 line
Reenable the manager tests with Amaury's threading fix
........
r64664 | facundo.batista | 2008-07-02 11:52:55 -0500 (Wed, 02 Jul 2008) | 4 lines
Issue #449227: Now with the rlcompleter module, callable objects are
added a '(' when completed.
........
2008-07-02 17:22:54 -03:00
|
|
|
if issubclass(klass, logging.handlers.MemoryHandler):
|
2010-11-10 14:57:39 -04:00
|
|
|
target = section.get("target", "")
|
2006-01-16 17:28:37 -04:00
|
|
|
if len(target): #the target handler may not be loaded yet, so keep for later...
|
|
|
|
fixups.append((h, target))
|
|
|
|
handlers[hand] = h
|
|
|
|
#now all handlers are loaded, fixup inter-handler references...
|
|
|
|
for h, t in fixups:
|
|
|
|
h.setTarget(handlers[t])
|
|
|
|
return handlers
|
|
|
|
|
2010-08-30 16:02:14 -03:00
|
|
|
def _handle_existing_loggers(existing, child_loggers, disable_existing):
|
|
|
|
"""
|
|
|
|
When (re)configuring logging, handle loggers which were in the previous
|
|
|
|
configuration but are not in the new configuration. There's no point
|
|
|
|
deleting them as other threads may continue to hold references to them;
|
|
|
|
and by disabling them, you stop them doing any logging.
|
|
|
|
|
|
|
|
However, don't disable children of named loggers, as that's probably not
|
|
|
|
what was intended by the user. Also, allow existing loggers to NOT be
|
|
|
|
disabled if disable_existing is false.
|
|
|
|
"""
|
|
|
|
root = logging.root
|
|
|
|
for log in existing:
|
|
|
|
logger = root.manager.loggerDict[log]
|
|
|
|
if log in child_loggers:
|
|
|
|
logger.level = logging.NOTSET
|
|
|
|
logger.handlers = []
|
|
|
|
logger.propagate = True
|
2013-03-23 08:18:45 -03:00
|
|
|
else:
|
|
|
|
logger.disabled = disable_existing
|
2006-01-16 17:28:37 -04:00
|
|
|
|
2010-08-30 16:02:14 -03:00
|
|
|
def _install_loggers(cp, handlers, disable_existing):
|
2006-01-16 17:28:37 -04:00
|
|
|
"""Create and install loggers"""
|
|
|
|
|
|
|
|
# configure the root first
|
2010-11-10 14:57:39 -04:00
|
|
|
llist = cp["loggers"]["keys"]
|
2007-04-17 05:48:32 -03:00
|
|
|
llist = llist.split(",")
|
Merged revisions 56125-56153 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
........
r56127 | georg.brandl | 2007-06-30 09:32:49 +0200 (Sat, 30 Jun 2007) | 2 lines
Fix a place where floor division would be in order.
........
r56135 | guido.van.rossum | 2007-07-01 06:13:54 +0200 (Sun, 01 Jul 2007) | 28 lines
Make map() and filter() identical to itertools.imap() and .ifilter(),
respectively.
I fixed two bootstrap issues, due to the dynamic import of itertools:
1. Starting python requires that map() and filter() are not used until
site.py has added build/lib.<arch> to sys.path.
2. Building python requires that setup.py and distutils and everything
they use is free of map() and filter() calls.
Beyond this, I only fixed the tests in test_builtin.py.
Others, please help fixing the remaining tests that are now broken!
The fixes are usually simple:
a. map(None, X) -> list(X)
b. map(F, X) -> list(map(F, X))
c. map(lambda x: F(x), X) -> [F(x) for x in X]
d. filter(F, X) -> list(filter(F, X))
e. filter(lambda x: P(x), X) -> [x for x in X if P(x)]
Someone, please also contribute a fixer for 2to3 to do this.
It can leave map()/filter() calls alone that are already
inside a list() or sorted() call or for-loop.
Only in rare cases have I seen code that depends on map() of lists
of different lengths going to the end of the longest, or on filter()
of a string or tuple returning an object of the same type; these
will need more thought to fix.
........
r56136 | guido.van.rossum | 2007-07-01 06:22:01 +0200 (Sun, 01 Jul 2007) | 3 lines
Make it so that test_decimal fails instead of hangs, to help automated
test runners.
........
r56139 | georg.brandl | 2007-07-01 18:20:58 +0200 (Sun, 01 Jul 2007) | 2 lines
Fix a few test cases after the map->imap change.
........
r56142 | neal.norwitz | 2007-07-02 06:38:12 +0200 (Mon, 02 Jul 2007) | 1 line
Get a bunch more tests passing after converting map/filter to return iterators.
........
r56147 | guido.van.rossum | 2007-07-02 15:32:02 +0200 (Mon, 02 Jul 2007) | 4 lines
Fix the remaining failing unit tests (at least on OSX).
Also tweaked urllib2 so it doesn't raise socket.gaierror when
all network interfaces are turned off.
........
2007-07-03 05:25:58 -03:00
|
|
|
llist = list(map(lambda x: x.strip(), llist))
|
2006-01-16 17:28:37 -04:00
|
|
|
llist.remove("root")
|
2010-11-10 14:57:39 -04:00
|
|
|
section = cp["logger_root"]
|
2006-01-16 17:28:37 -04:00
|
|
|
root = logging.root
|
|
|
|
log = root
|
2010-11-10 14:57:39 -04:00
|
|
|
if "level" in section:
|
|
|
|
level = section["level"]
|
2006-01-16 17:28:37 -04:00
|
|
|
log.setLevel(logging._levelNames[level])
|
|
|
|
for h in root.handlers[:]:
|
|
|
|
root.removeHandler(h)
|
2010-11-10 14:57:39 -04:00
|
|
|
hlist = section["handlers"]
|
2006-01-16 17:28:37 -04:00
|
|
|
if len(hlist):
|
2007-04-17 05:48:32 -03:00
|
|
|
hlist = hlist.split(",")
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
hlist = _strip_spaces(hlist)
|
2006-01-16 17:28:37 -04:00
|
|
|
for hand in hlist:
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
log.addHandler(handlers[hand])
|
2006-01-16 17:28:37 -04:00
|
|
|
|
|
|
|
#and now the others...
|
|
|
|
#we don't want to lose the existing loggers,
|
|
|
|
#since other threads may have pointers to them.
|
|
|
|
#existing is set to contain all existing loggers,
|
|
|
|
#and as we go through the new configuration we
|
|
|
|
#remove any which are configured. At the end,
|
|
|
|
#what's left in existing is the set of loggers
|
|
|
|
#which were in the previous configuration but
|
|
|
|
#which are not in the new configuration.
|
2007-02-11 20:07:01 -04:00
|
|
|
existing = list(root.manager.loggerDict.keys())
|
2007-11-11 21:32:03 -04:00
|
|
|
#The list needs to be sorted so that we can
|
|
|
|
#avoid disabling child loggers of explicitly
|
|
|
|
#named loggers. With a sorted list it is easier
|
|
|
|
#to find the child loggers.
|
2011-11-07 14:43:05 -04:00
|
|
|
existing.sort()
|
2007-11-11 21:32:03 -04:00
|
|
|
#We'll keep the list of existing loggers
|
|
|
|
#which are children of named loggers here...
|
|
|
|
child_loggers = []
|
2006-01-16 17:28:37 -04:00
|
|
|
#now set up the new ones...
|
|
|
|
for log in llist:
|
2010-11-10 14:57:39 -04:00
|
|
|
section = cp["logger_%s" % log]
|
|
|
|
qn = section["qualname"]
|
|
|
|
propagate = section.getint("propagate", fallback=1)
|
2006-01-16 17:28:37 -04:00
|
|
|
logger = logging.getLogger(qn)
|
|
|
|
if qn in existing:
|
2011-03-07 13:49:33 -04:00
|
|
|
i = existing.index(qn) + 1 # start with the entry after qn
|
2007-11-11 21:32:03 -04:00
|
|
|
prefixed = qn + "."
|
|
|
|
pflen = len(prefixed)
|
|
|
|
num_existing = len(existing)
|
2011-03-07 13:49:33 -04:00
|
|
|
while i < num_existing:
|
|
|
|
if existing[i][:pflen] == prefixed:
|
|
|
|
child_loggers.append(existing[i])
|
|
|
|
i += 1
|
2006-01-16 17:28:37 -04:00
|
|
|
existing.remove(qn)
|
2010-11-10 14:57:39 -04:00
|
|
|
if "level" in section:
|
|
|
|
level = section["level"]
|
2006-01-16 17:28:37 -04:00
|
|
|
logger.setLevel(logging._levelNames[level])
|
|
|
|
for h in logger.handlers[:]:
|
|
|
|
logger.removeHandler(h)
|
|
|
|
logger.propagate = propagate
|
|
|
|
logger.disabled = 0
|
2010-11-10 14:57:39 -04:00
|
|
|
hlist = section["handlers"]
|
2006-01-16 17:28:37 -04:00
|
|
|
if len(hlist):
|
2007-04-17 05:48:32 -03:00
|
|
|
hlist = hlist.split(",")
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
hlist = _strip_spaces(hlist)
|
2006-01-16 17:28:37 -04:00
|
|
|
for hand in hlist:
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
logger.addHandler(handlers[hand])
|
2006-01-16 17:28:37 -04:00
|
|
|
|
|
|
|
#Disable any old loggers. There's no point deleting
|
|
|
|
#them as other threads may continue to hold references
|
|
|
|
#and by disabling them, you stop them doing any logging.
|
2007-11-11 21:32:03 -04:00
|
|
|
#However, don't disable children of named loggers, as that's
|
|
|
|
#probably not what was intended by the user.
|
2010-08-30 16:02:14 -03:00
|
|
|
#for log in existing:
|
|
|
|
# logger = root.manager.loggerDict[log]
|
|
|
|
# if log in child_loggers:
|
|
|
|
# logger.level = logging.NOTSET
|
|
|
|
# logger.handlers = []
|
|
|
|
# logger.propagate = 1
|
|
|
|
# elif disable_existing_loggers:
|
|
|
|
# logger.disabled = 1
|
|
|
|
_handle_existing_loggers(existing, child_loggers, disable_existing)
|
2006-01-16 17:28:37 -04:00
|
|
|
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
IDENTIFIER = re.compile('^[a-z_][a-z0-9_]*$', re.I)
|
|
|
|
|
|
|
|
|
|
|
|
def valid_ident(s):
|
|
|
|
m = IDENTIFIER.match(s)
|
|
|
|
if not m:
|
|
|
|
raise ValueError('Not a valid Python identifier: %r' % s)
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
# The ConvertingXXX classes are wrappers around standard Python containers,
|
|
|
|
# and they serve to convert any suitable values in the container. The
|
|
|
|
# conversion converts base dicts, lists and tuples to their wrapped
|
|
|
|
# equivalents, whereas strings which match a conversion format are converted
|
|
|
|
# appropriately.
|
|
|
|
#
|
|
|
|
# Each wrapper should have a configurator attribute holding the actual
|
|
|
|
# configurator to use for conversion.
|
|
|
|
|
|
|
|
class ConvertingDict(dict):
|
|
|
|
"""A converting dictionary wrapper."""
|
|
|
|
|
|
|
|
def __getitem__(self, key):
|
|
|
|
value = dict.__getitem__(self, key)
|
|
|
|
result = self.configurator.convert(value)
|
|
|
|
#If the converted value is different, save for next time
|
|
|
|
if value is not result:
|
|
|
|
self[key] = result
|
|
|
|
if type(result) in (ConvertingDict, ConvertingList,
|
|
|
|
ConvertingTuple):
|
|
|
|
result.parent = self
|
|
|
|
result.key = key
|
|
|
|
return result
|
|
|
|
|
|
|
|
def get(self, key, default=None):
|
|
|
|
value = dict.get(self, key, default)
|
|
|
|
result = self.configurator.convert(value)
|
|
|
|
#If the converted value is different, save for next time
|
|
|
|
if value is not result:
|
|
|
|
self[key] = result
|
|
|
|
if type(result) in (ConvertingDict, ConvertingList,
|
|
|
|
ConvertingTuple):
|
|
|
|
result.parent = self
|
|
|
|
result.key = key
|
|
|
|
return result
|
|
|
|
|
|
|
|
def pop(self, key, default=None):
|
|
|
|
value = dict.pop(self, key, default)
|
|
|
|
result = self.configurator.convert(value)
|
|
|
|
if value is not result:
|
|
|
|
if type(result) in (ConvertingDict, ConvertingList,
|
|
|
|
ConvertingTuple):
|
|
|
|
result.parent = self
|
|
|
|
result.key = key
|
|
|
|
return result
|
|
|
|
|
|
|
|
class ConvertingList(list):
|
|
|
|
"""A converting list wrapper."""
|
|
|
|
def __getitem__(self, key):
|
|
|
|
value = list.__getitem__(self, key)
|
|
|
|
result = self.configurator.convert(value)
|
|
|
|
#If the converted value is different, save for next time
|
|
|
|
if value is not result:
|
|
|
|
self[key] = result
|
|
|
|
if type(result) in (ConvertingDict, ConvertingList,
|
|
|
|
ConvertingTuple):
|
|
|
|
result.parent = self
|
|
|
|
result.key = key
|
|
|
|
return result
|
|
|
|
|
|
|
|
def pop(self, idx=-1):
|
|
|
|
value = list.pop(self, idx)
|
|
|
|
result = self.configurator.convert(value)
|
|
|
|
if value is not result:
|
|
|
|
if type(result) in (ConvertingDict, ConvertingList,
|
|
|
|
ConvertingTuple):
|
|
|
|
result.parent = self
|
|
|
|
return result
|
|
|
|
|
|
|
|
class ConvertingTuple(tuple):
|
|
|
|
"""A converting tuple wrapper."""
|
|
|
|
def __getitem__(self, key):
|
|
|
|
value = tuple.__getitem__(self, key)
|
|
|
|
result = self.configurator.convert(value)
|
|
|
|
if value is not result:
|
|
|
|
if type(result) in (ConvertingDict, ConvertingList,
|
|
|
|
ConvertingTuple):
|
|
|
|
result.parent = self
|
|
|
|
result.key = key
|
|
|
|
return result
|
|
|
|
|
|
|
|
class BaseConfigurator(object):
|
|
|
|
"""
|
|
|
|
The configurator base class which defines some useful defaults.
|
|
|
|
"""
|
|
|
|
|
|
|
|
CONVERT_PATTERN = re.compile(r'^(?P<prefix>[a-z]+)://(?P<suffix>.*)$')
|
|
|
|
|
|
|
|
WORD_PATTERN = re.compile(r'^\s*(\w+)\s*')
|
|
|
|
DOT_PATTERN = re.compile(r'^\.\s*(\w+)\s*')
|
|
|
|
INDEX_PATTERN = re.compile(r'^\[\s*(\w+)\s*\]\s*')
|
|
|
|
DIGIT_PATTERN = re.compile(r'^\d+$')
|
|
|
|
|
|
|
|
value_converters = {
|
|
|
|
'ext' : 'ext_convert',
|
|
|
|
'cfg' : 'cfg_convert',
|
|
|
|
}
|
|
|
|
|
|
|
|
# We might want to use a different one, e.g. importlib
|
2010-06-11 21:39:28 -03:00
|
|
|
importer = staticmethod(__import__)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
|
|
|
|
def __init__(self, config):
|
|
|
|
self.config = ConvertingDict(config)
|
|
|
|
self.config.configurator = self
|
|
|
|
|
|
|
|
def resolve(self, s):
|
|
|
|
"""
|
|
|
|
Resolve strings to objects using standard import and attribute
|
|
|
|
syntax.
|
|
|
|
"""
|
|
|
|
name = s.split('.')
|
|
|
|
used = name.pop(0)
|
2010-06-27 17:54:28 -03:00
|
|
|
try:
|
|
|
|
found = self.importer(used)
|
|
|
|
for frag in name:
|
|
|
|
used += '.' + frag
|
|
|
|
try:
|
|
|
|
found = getattr(found, frag)
|
|
|
|
except AttributeError:
|
|
|
|
self.importer(used)
|
|
|
|
found = getattr(found, frag)
|
|
|
|
return found
|
|
|
|
except ImportError:
|
|
|
|
e, tb = sys.exc_info()[1:]
|
|
|
|
v = ValueError('Cannot resolve %r: %s' % (s, e))
|
|
|
|
v.__cause__, v.__traceback__ = e, tb
|
|
|
|
raise v
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
|
|
|
|
def ext_convert(self, value):
|
|
|
|
"""Default converter for the ext:// protocol."""
|
|
|
|
return self.resolve(value)
|
|
|
|
|
|
|
|
def cfg_convert(self, value):
|
|
|
|
"""Default converter for the cfg:// protocol."""
|
|
|
|
rest = value
|
|
|
|
m = self.WORD_PATTERN.match(rest)
|
|
|
|
if m is None:
|
|
|
|
raise ValueError("Unable to convert %r" % value)
|
|
|
|
else:
|
|
|
|
rest = rest[m.end():]
|
|
|
|
d = self.config[m.groups()[0]]
|
|
|
|
#print d, rest
|
|
|
|
while rest:
|
|
|
|
m = self.DOT_PATTERN.match(rest)
|
|
|
|
if m:
|
|
|
|
d = d[m.groups()[0]]
|
|
|
|
else:
|
|
|
|
m = self.INDEX_PATTERN.match(rest)
|
|
|
|
if m:
|
|
|
|
idx = m.groups()[0]
|
|
|
|
if not self.DIGIT_PATTERN.match(idx):
|
|
|
|
d = d[idx]
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
n = int(idx) # try as number first (most likely)
|
|
|
|
d = d[n]
|
|
|
|
except TypeError:
|
|
|
|
d = d[idx]
|
|
|
|
if m:
|
|
|
|
rest = rest[m.end():]
|
|
|
|
else:
|
|
|
|
raise ValueError('Unable to convert '
|
|
|
|
'%r at %r' % (value, rest))
|
|
|
|
#rest should be empty
|
|
|
|
return d
|
|
|
|
|
|
|
|
def convert(self, value):
|
|
|
|
"""
|
|
|
|
Convert values to an appropriate type. dicts, lists and tuples are
|
|
|
|
replaced by their converting alternatives. Strings are checked to
|
|
|
|
see if they have a conversion format and are converted if they do.
|
|
|
|
"""
|
|
|
|
if not isinstance(value, ConvertingDict) and isinstance(value, dict):
|
|
|
|
value = ConvertingDict(value)
|
|
|
|
value.configurator = self
|
|
|
|
elif not isinstance(value, ConvertingList) and isinstance(value, list):
|
|
|
|
value = ConvertingList(value)
|
|
|
|
value.configurator = self
|
|
|
|
elif not isinstance(value, ConvertingTuple) and\
|
|
|
|
isinstance(value, tuple):
|
|
|
|
value = ConvertingTuple(value)
|
|
|
|
value.configurator = self
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
elif isinstance(value, str): # str for py3k
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
m = self.CONVERT_PATTERN.match(value)
|
|
|
|
if m:
|
|
|
|
d = m.groupdict()
|
|
|
|
prefix = d['prefix']
|
|
|
|
converter = self.value_converters.get(prefix, None)
|
|
|
|
if converter:
|
|
|
|
suffix = d['suffix']
|
|
|
|
converter = getattr(self, converter)
|
|
|
|
value = converter(suffix)
|
|
|
|
return value
|
|
|
|
|
|
|
|
def configure_custom(self, config):
|
|
|
|
"""Configure an object with a user-supplied factory."""
|
|
|
|
c = config.pop('()')
|
2011-10-28 09:45:05 -03:00
|
|
|
if not callable(c):
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
c = self.resolve(c)
|
|
|
|
props = config.pop('.', None)
|
|
|
|
# Check for valid identifiers
|
|
|
|
kwargs = dict([(k, config[k]) for k in config if valid_ident(k)])
|
|
|
|
result = c(**kwargs)
|
|
|
|
if props:
|
|
|
|
for name, value in props.items():
|
|
|
|
setattr(result, name, value)
|
|
|
|
return result
|
|
|
|
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
def as_tuple(self, value):
|
|
|
|
"""Utility function which converts lists to tuples."""
|
|
|
|
if isinstance(value, list):
|
|
|
|
value = tuple(value)
|
|
|
|
return value
|
|
|
|
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
class DictConfigurator(BaseConfigurator):
|
|
|
|
"""
|
|
|
|
Configure logging using a dictionary-like object to describe the
|
|
|
|
configuration.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def configure(self):
|
|
|
|
"""Do the configuration."""
|
|
|
|
|
|
|
|
config = self.config
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
if 'version' not in config:
|
|
|
|
raise ValueError("dictionary doesn't specify a version")
|
|
|
|
if config['version'] != 1:
|
|
|
|
raise ValueError("Unsupported version: %s" % config['version'])
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
incremental = config.pop('incremental', False)
|
|
|
|
EMPTY_DICT = {}
|
|
|
|
logging._acquireLock()
|
|
|
|
try:
|
|
|
|
if incremental:
|
|
|
|
handlers = config.get('handlers', EMPTY_DICT)
|
|
|
|
for name in handlers:
|
|
|
|
if name not in logging._handlers:
|
|
|
|
raise ValueError('No handler found with '
|
|
|
|
'name %r' % name)
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
handler = logging._handlers[name]
|
|
|
|
handler_config = handlers[name]
|
|
|
|
level = handler_config.get('level', None)
|
|
|
|
if level:
|
|
|
|
handler.setLevel(logging._checkLevel(level))
|
|
|
|
except Exception as e:
|
|
|
|
raise ValueError('Unable to configure handler '
|
|
|
|
'%r: %s' % (name, e))
|
|
|
|
loggers = config.get('loggers', EMPTY_DICT)
|
|
|
|
for name in loggers:
|
|
|
|
try:
|
|
|
|
self.configure_logger(name, loggers[name], True)
|
|
|
|
except Exception as e:
|
|
|
|
raise ValueError('Unable to configure logger '
|
|
|
|
'%r: %s' % (name, e))
|
|
|
|
root = config.get('root', None)
|
|
|
|
if root:
|
|
|
|
try:
|
|
|
|
self.configure_root(root, True)
|
|
|
|
except Exception as e:
|
|
|
|
raise ValueError('Unable to configure root '
|
|
|
|
'logger: %s' % e)
|
|
|
|
else:
|
|
|
|
disable_existing = config.pop('disable_existing_loggers', True)
|
|
|
|
|
|
|
|
logging._handlers.clear()
|
|
|
|
del logging._handlerList[:]
|
|
|
|
|
|
|
|
# Do formatters first - they don't refer to anything else
|
|
|
|
formatters = config.get('formatters', EMPTY_DICT)
|
|
|
|
for name in formatters:
|
|
|
|
try:
|
|
|
|
formatters[name] = self.configure_formatter(
|
|
|
|
formatters[name])
|
|
|
|
except Exception as e:
|
|
|
|
raise ValueError('Unable to configure '
|
|
|
|
'formatter %r: %s' % (name, e))
|
|
|
|
# Next, do filters - they don't refer to anything else, either
|
|
|
|
filters = config.get('filters', EMPTY_DICT)
|
|
|
|
for name in filters:
|
|
|
|
try:
|
|
|
|
filters[name] = self.configure_filter(filters[name])
|
|
|
|
except Exception as e:
|
|
|
|
raise ValueError('Unable to configure '
|
|
|
|
'filter %r: %s' % (name, e))
|
|
|
|
|
|
|
|
# Next, do handlers - they refer to formatters and filters
|
|
|
|
# As handlers can refer to other handlers, sort the keys
|
|
|
|
# to allow a deterministic order of configuration
|
|
|
|
handlers = config.get('handlers', EMPTY_DICT)
|
2013-03-22 12:19:54 -03:00
|
|
|
deferred = []
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
for name in sorted(handlers):
|
2013-03-22 12:19:54 -03:00
|
|
|
try:
|
|
|
|
handler = self.configure_handler(handlers[name])
|
|
|
|
handler.name = name
|
|
|
|
handlers[name] = handler
|
|
|
|
except Exception as e:
|
|
|
|
if 'target not configured yet' in str(e):
|
|
|
|
deferred.append(name)
|
|
|
|
else:
|
|
|
|
raise ValueError('Unable to configure handler '
|
|
|
|
'%r: %s' % (name, e))
|
|
|
|
|
|
|
|
# Now do any that were deferred
|
|
|
|
for name in deferred:
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
try:
|
|
|
|
handler = self.configure_handler(handlers[name])
|
|
|
|
handler.name = name
|
|
|
|
handlers[name] = handler
|
|
|
|
except Exception as e:
|
|
|
|
raise ValueError('Unable to configure handler '
|
|
|
|
'%r: %s' % (name, e))
|
2013-03-22 12:19:54 -03:00
|
|
|
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
# Next, do loggers - they refer to handlers and filters
|
|
|
|
|
|
|
|
#we don't want to lose the existing loggers,
|
|
|
|
#since other threads may have pointers to them.
|
|
|
|
#existing is set to contain all existing loggers,
|
|
|
|
#and as we go through the new configuration we
|
|
|
|
#remove any which are configured. At the end,
|
|
|
|
#what's left in existing is the set of loggers
|
|
|
|
#which were in the previous configuration but
|
|
|
|
#which are not in the new configuration.
|
|
|
|
root = logging.root
|
|
|
|
existing = list(root.manager.loggerDict.keys())
|
|
|
|
#The list needs to be sorted so that we can
|
|
|
|
#avoid disabling child loggers of explicitly
|
|
|
|
#named loggers. With a sorted list it is easier
|
|
|
|
#to find the child loggers.
|
2011-11-07 14:43:05 -04:00
|
|
|
existing.sort()
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
#We'll keep the list of existing loggers
|
|
|
|
#which are children of named loggers here...
|
|
|
|
child_loggers = []
|
|
|
|
#now set up the new ones...
|
|
|
|
loggers = config.get('loggers', EMPTY_DICT)
|
|
|
|
for name in loggers:
|
|
|
|
if name in existing:
|
2011-03-07 14:02:57 -04:00
|
|
|
i = existing.index(name) + 1 # look after name
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
prefixed = name + "."
|
|
|
|
pflen = len(prefixed)
|
|
|
|
num_existing = len(existing)
|
2011-03-07 14:02:57 -04:00
|
|
|
while i < num_existing:
|
|
|
|
if existing[i][:pflen] == prefixed:
|
|
|
|
child_loggers.append(existing[i])
|
|
|
|
i += 1
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
existing.remove(name)
|
|
|
|
try:
|
|
|
|
self.configure_logger(name, loggers[name])
|
|
|
|
except Exception as e:
|
|
|
|
raise ValueError('Unable to configure logger '
|
|
|
|
'%r: %s' % (name, e))
|
|
|
|
|
|
|
|
#Disable any old loggers. There's no point deleting
|
|
|
|
#them as other threads may continue to hold references
|
|
|
|
#and by disabling them, you stop them doing any logging.
|
|
|
|
#However, don't disable children of named loggers, as that's
|
|
|
|
#probably not what was intended by the user.
|
2010-08-30 16:02:14 -03:00
|
|
|
#for log in existing:
|
|
|
|
# logger = root.manager.loggerDict[log]
|
|
|
|
# if log in child_loggers:
|
|
|
|
# logger.level = logging.NOTSET
|
|
|
|
# logger.handlers = []
|
|
|
|
# logger.propagate = True
|
|
|
|
# elif disable_existing:
|
|
|
|
# logger.disabled = True
|
|
|
|
_handle_existing_loggers(existing, child_loggers,
|
|
|
|
disable_existing)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
|
|
|
|
# And finally, do the root logger
|
|
|
|
root = config.get('root', None)
|
|
|
|
if root:
|
|
|
|
try:
|
|
|
|
self.configure_root(root)
|
|
|
|
except Exception as e:
|
|
|
|
raise ValueError('Unable to configure root '
|
|
|
|
'logger: %s' % e)
|
|
|
|
finally:
|
|
|
|
logging._releaseLock()
|
|
|
|
|
|
|
|
def configure_formatter(self, config):
|
|
|
|
"""Configure a formatter from a dictionary."""
|
|
|
|
if '()' in config:
|
|
|
|
factory = config['()'] # for use in exception handler
|
|
|
|
try:
|
|
|
|
result = self.configure_custom(config)
|
|
|
|
except TypeError as te:
|
|
|
|
if "'format'" not in str(te):
|
|
|
|
raise
|
|
|
|
#Name of parameter changed from fmt to format.
|
|
|
|
#Retry with old name.
|
|
|
|
#This is so that code can be used with older Python versions
|
|
|
|
#(e.g. by Django)
|
|
|
|
config['fmt'] = config.pop('format')
|
|
|
|
config['()'] = factory
|
|
|
|
result = self.configure_custom(config)
|
|
|
|
else:
|
|
|
|
fmt = config.get('format', None)
|
|
|
|
dfmt = config.get('datefmt', None)
|
2013-03-29 14:56:54 -03:00
|
|
|
style = config.get('style', '%')
|
|
|
|
result = logging.Formatter(fmt, dfmt, style)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
return result
|
|
|
|
|
|
|
|
def configure_filter(self, config):
|
|
|
|
"""Configure a filter from a dictionary."""
|
|
|
|
if '()' in config:
|
|
|
|
result = self.configure_custom(config)
|
|
|
|
else:
|
|
|
|
name = config.get('name', '')
|
|
|
|
result = logging.Filter(name)
|
|
|
|
return result
|
|
|
|
|
|
|
|
def add_filters(self, filterer, filters):
|
|
|
|
"""Add filters to a filterer from a list of names."""
|
|
|
|
for f in filters:
|
|
|
|
try:
|
|
|
|
filterer.addFilter(self.config['filters'][f])
|
|
|
|
except Exception as e:
|
|
|
|
raise ValueError('Unable to add filter %r: %s' % (f, e))
|
|
|
|
|
|
|
|
def configure_handler(self, config):
|
|
|
|
"""Configure a handler from a dictionary."""
|
2013-03-29 14:56:54 -03:00
|
|
|
config_copy = dict(config) # for restoring in case of error
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
formatter = config.pop('formatter', None)
|
|
|
|
if formatter:
|
|
|
|
try:
|
|
|
|
formatter = self.config['formatters'][formatter]
|
|
|
|
except Exception as e:
|
|
|
|
raise ValueError('Unable to set formatter '
|
|
|
|
'%r: %s' % (formatter, e))
|
|
|
|
level = config.pop('level', None)
|
|
|
|
filters = config.pop('filters', None)
|
|
|
|
if '()' in config:
|
|
|
|
c = config.pop('()')
|
2011-10-28 09:45:05 -03:00
|
|
|
if not callable(c):
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
c = self.resolve(c)
|
|
|
|
factory = c
|
|
|
|
else:
|
2013-03-22 12:19:54 -03:00
|
|
|
cname = config.pop('class')
|
|
|
|
klass = self.resolve(cname)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
#Special case for handler which refers to another handler
|
|
|
|
if issubclass(klass, logging.handlers.MemoryHandler) and\
|
|
|
|
'target' in config:
|
|
|
|
try:
|
2013-03-22 12:19:54 -03:00
|
|
|
th = self.config['handlers'][config['target']]
|
|
|
|
if not isinstance(th, logging.Handler):
|
2013-03-29 14:56:54 -03:00
|
|
|
config.update(config_copy) # restore for deferred cfg
|
2013-03-22 12:19:54 -03:00
|
|
|
raise TypeError('target not configured yet')
|
|
|
|
config['target'] = th
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
except Exception as e:
|
|
|
|
raise ValueError('Unable to set target handler '
|
|
|
|
'%r: %s' % (config['target'], e))
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
elif issubclass(klass, logging.handlers.SMTPHandler) and\
|
|
|
|
'mailhost' in config:
|
|
|
|
config['mailhost'] = self.as_tuple(config['mailhost'])
|
|
|
|
elif issubclass(klass, logging.handlers.SysLogHandler) and\
|
|
|
|
'address' in config:
|
|
|
|
config['address'] = self.as_tuple(config['address'])
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
factory = klass
|
2012-11-15 10:20:18 -04:00
|
|
|
props = config.pop('.', None)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
kwargs = dict([(k, config[k]) for k in config if valid_ident(k)])
|
|
|
|
try:
|
|
|
|
result = factory(**kwargs)
|
|
|
|
except TypeError as te:
|
|
|
|
if "'stream'" not in str(te):
|
|
|
|
raise
|
|
|
|
#The argument name changed from strm to stream
|
|
|
|
#Retry with old name.
|
|
|
|
#This is so that code can be used with older Python versions
|
|
|
|
#(e.g. by Django)
|
|
|
|
kwargs['strm'] = kwargs.pop('stream')
|
|
|
|
result = factory(**kwargs)
|
|
|
|
if formatter:
|
|
|
|
result.setFormatter(formatter)
|
|
|
|
if level is not None:
|
|
|
|
result.setLevel(logging._checkLevel(level))
|
|
|
|
if filters:
|
|
|
|
self.add_filters(result, filters)
|
2012-11-15 10:20:18 -04:00
|
|
|
if props:
|
|
|
|
for name, value in props.items():
|
|
|
|
setattr(result, name, value)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
return result
|
|
|
|
|
|
|
|
def add_handlers(self, logger, handlers):
|
|
|
|
"""Add handlers to a logger from a list of names."""
|
|
|
|
for h in handlers:
|
|
|
|
try:
|
|
|
|
logger.addHandler(self.config['handlers'][h])
|
|
|
|
except Exception as e:
|
|
|
|
raise ValueError('Unable to add handler %r: %s' % (h, e))
|
|
|
|
|
|
|
|
def common_logger_config(self, logger, config, incremental=False):
|
|
|
|
"""
|
|
|
|
Perform configuration which is common to root and non-root loggers.
|
|
|
|
"""
|
|
|
|
level = config.get('level', None)
|
|
|
|
if level is not None:
|
|
|
|
logger.setLevel(logging._checkLevel(level))
|
|
|
|
if not incremental:
|
|
|
|
#Remove any existing handlers
|
|
|
|
for h in logger.handlers[:]:
|
|
|
|
logger.removeHandler(h)
|
|
|
|
handlers = config.get('handlers', None)
|
|
|
|
if handlers:
|
|
|
|
self.add_handlers(logger, handlers)
|
|
|
|
filters = config.get('filters', None)
|
|
|
|
if filters:
|
|
|
|
self.add_filters(logger, filters)
|
|
|
|
|
|
|
|
def configure_logger(self, name, config, incremental=False):
|
|
|
|
"""Configure a non-root logger from a dictionary."""
|
|
|
|
logger = logging.getLogger(name)
|
|
|
|
self.common_logger_config(logger, config, incremental)
|
|
|
|
propagate = config.get('propagate', None)
|
|
|
|
if propagate is not None:
|
|
|
|
logger.propagate = propagate
|
|
|
|
|
|
|
|
def configure_root(self, config, incremental=False):
|
|
|
|
"""Configure a root logger from a dictionary."""
|
|
|
|
root = logging.getLogger()
|
|
|
|
self.common_logger_config(root, config, incremental)
|
|
|
|
|
|
|
|
dictConfigClass = DictConfigurator
|
|
|
|
|
|
|
|
def dictConfig(config):
|
|
|
|
"""Configure logging using a dictionary."""
|
|
|
|
dictConfigClass(config).configure()
|
|
|
|
|
|
|
|
|
2012-10-02 11:56:16 -03:00
|
|
|
def listen(port=DEFAULT_LOGGING_CONFIG_PORT, verify=None):
|
2002-11-13 12:15:58 -04:00
|
|
|
"""
|
|
|
|
Start up a socket server on the specified port, and listen for new
|
|
|
|
configurations.
|
|
|
|
|
|
|
|
These will be sent as a file suitable for processing by fileConfig().
|
|
|
|
Returns a Thread object on which you can call start() to start the server,
|
|
|
|
and which you can join() when appropriate. To stop the server, call
|
|
|
|
stopListening().
|
2012-10-02 12:15:33 -03:00
|
|
|
|
|
|
|
Use the ``verify`` argument to verify any bytes received across the wire
|
|
|
|
from a client. If specified, it should be a callable which receives a
|
|
|
|
single argument - the bytes of configuration data received across the
|
|
|
|
network - and it should return either ``None``, to indicate that the
|
|
|
|
passed in bytes could not be verified and should be discarded, or a
|
|
|
|
byte string which is then passed to the configuration machinery as
|
|
|
|
normal. Note that you can return transformed bytes, e.g. by decrypting
|
|
|
|
the bytes passed in.
|
2002-11-13 12:15:58 -04:00
|
|
|
"""
|
2011-04-26 15:34:04 -03:00
|
|
|
if not thread: #pragma: no cover
|
2007-08-29 22:19:48 -03:00
|
|
|
raise NotImplementedError("listen() needs threading to work")
|
2002-11-13 12:15:58 -04:00
|
|
|
|
|
|
|
class ConfigStreamHandler(StreamRequestHandler):
|
|
|
|
"""
|
|
|
|
Handler for a logging configuration request.
|
|
|
|
|
|
|
|
It expects a completely new logging configuration and uses fileConfig
|
|
|
|
to install it.
|
|
|
|
"""
|
|
|
|
def handle(self):
|
|
|
|
"""
|
|
|
|
Handle a request.
|
|
|
|
|
2005-06-05 17:39:36 -03:00
|
|
|
Each request is expected to be a 4-byte length, packed using
|
|
|
|
struct.pack(">L", n), followed by the config file.
|
|
|
|
Uses fileConfig() to do the grunt work.
|
2002-11-13 12:15:58 -04:00
|
|
|
"""
|
|
|
|
try:
|
|
|
|
conn = self.connection
|
|
|
|
chunk = conn.recv(4)
|
|
|
|
if len(chunk) == 4:
|
|
|
|
slen = struct.unpack(">L", chunk)[0]
|
|
|
|
chunk = self.connection.recv(slen)
|
|
|
|
while len(chunk) < slen:
|
|
|
|
chunk = chunk + conn.recv(slen - len(chunk))
|
2012-10-02 11:56:16 -03:00
|
|
|
if self.server.verify is not None:
|
|
|
|
chunk = self.server.verify(chunk)
|
|
|
|
if chunk is not None: # verified, can process
|
|
|
|
chunk = chunk.decode("utf-8")
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
try:
|
2012-10-02 11:56:16 -03:00
|
|
|
import json
|
|
|
|
d =json.loads(chunk)
|
|
|
|
assert isinstance(d, dict)
|
|
|
|
dictConfig(d)
|
2012-10-09 04:06:13 -03:00
|
|
|
except Exception:
|
2012-10-02 11:56:16 -03:00
|
|
|
#Apply new configuration.
|
|
|
|
|
|
|
|
file = io.StringIO(chunk)
|
|
|
|
try:
|
|
|
|
fileConfig(file)
|
2012-10-09 04:06:13 -03:00
|
|
|
except Exception:
|
2012-10-02 11:56:16 -03:00
|
|
|
traceback.print_exc()
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
if self.server.ready:
|
|
|
|
self.server.ready.set()
|
2012-12-18 17:10:48 -04:00
|
|
|
except OSError as e:
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
if not isinstance(e.args, tuple):
|
2002-11-13 12:15:58 -04:00
|
|
|
raise
|
|
|
|
else:
|
|
|
|
errcode = e.args[0]
|
|
|
|
if errcode != RESET_ERROR:
|
|
|
|
raise
|
|
|
|
|
|
|
|
class ConfigSocketReceiver(ThreadingTCPServer):
|
|
|
|
"""
|
|
|
|
A simple TCP socket-based logging config receiver.
|
|
|
|
"""
|
|
|
|
|
|
|
|
allow_reuse_address = 1
|
|
|
|
|
|
|
|
def __init__(self, host='localhost', port=DEFAULT_LOGGING_CONFIG_PORT,
|
2012-10-02 11:56:16 -03:00
|
|
|
handler=None, ready=None, verify=None):
|
2002-11-13 12:15:58 -04:00
|
|
|
ThreadingTCPServer.__init__(self, (host, port), handler)
|
|
|
|
logging._acquireLock()
|
|
|
|
self.abort = 0
|
|
|
|
logging._releaseLock()
|
|
|
|
self.timeout = 1
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
self.ready = ready
|
2012-10-02 11:56:16 -03:00
|
|
|
self.verify = verify
|
2002-11-13 12:15:58 -04:00
|
|
|
|
|
|
|
def serve_until_stopped(self):
|
|
|
|
import select
|
|
|
|
abort = 0
|
|
|
|
while not abort:
|
|
|
|
rd, wr, ex = select.select([self.socket.fileno()],
|
|
|
|
[], [],
|
|
|
|
self.timeout)
|
|
|
|
if rd:
|
|
|
|
self.handle_request()
|
|
|
|
logging._acquireLock()
|
|
|
|
abort = self.abort
|
|
|
|
logging._releaseLock()
|
2010-10-31 01:40:53 -03:00
|
|
|
self.socket.close()
|
2002-11-13 12:15:58 -04:00
|
|
|
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
class Server(threading.Thread):
|
|
|
|
|
2012-10-02 11:56:16 -03:00
|
|
|
def __init__(self, rcvr, hdlr, port, verify):
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
super(Server, self).__init__()
|
|
|
|
self.rcvr = rcvr
|
|
|
|
self.hdlr = hdlr
|
|
|
|
self.port = port
|
2012-10-02 11:56:16 -03:00
|
|
|
self.verify = verify
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
self.ready = threading.Event()
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
server = self.rcvr(port=self.port, handler=self.hdlr,
|
2012-10-02 11:56:16 -03:00
|
|
|
ready=self.ready,
|
|
|
|
verify=self.verify)
|
2010-06-27 17:54:28 -03:00
|
|
|
if self.port == 0:
|
|
|
|
self.port = server.server_address[1]
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
self.ready.set()
|
|
|
|
global _listener
|
|
|
|
logging._acquireLock()
|
|
|
|
_listener = server
|
|
|
|
logging._releaseLock()
|
|
|
|
server.serve_until_stopped()
|
2002-11-13 12:15:58 -04:00
|
|
|
|
2012-10-02 11:56:16 -03:00
|
|
|
return Server(ConfigSocketReceiver, ConfigStreamHandler, port, verify)
|
2002-11-13 12:15:58 -04:00
|
|
|
|
|
|
|
def stopListening():
|
|
|
|
"""
|
|
|
|
Stop the listening server which was created with a call to listen().
|
|
|
|
"""
|
2002-11-15 19:33:20 -04:00
|
|
|
global _listener
|
2010-09-25 14:48:25 -03:00
|
|
|
logging._acquireLock()
|
|
|
|
try:
|
|
|
|
if _listener:
|
|
|
|
_listener.abort = 1
|
|
|
|
_listener = None
|
|
|
|
finally:
|
2002-11-13 12:15:58 -04:00
|
|
|
logging._releaseLock()
|