Mario Frasca wrote at 2006-11-22 22:26 +0100:
> ....
>> I have seen discarded logging generate a quadratic runtime behavior:
>>
>> This occured as follows: [...]
>
>funny. but this is not a problem here, since discarding a logging call
>is done just based on the 'level' of the logger and the 'level' of the
>message. if the message level is below the logger level, then the
>logger returns immediately.
You have not read carefully enough:
The logger used (while not the Python logger) has had the same
behaviour -- it discarded messages based on the log level.
*BUT* the quadadric runtime went into determining the
parameters for the logging call -- spent before the logger
could discard the entry.
>as stated before, I feel that logging is an important part of a piece
>of software. we have a standard logging module. we are writing a set
>of directives for writing modules. these directives could prescribe
>the way to make use of the standard logging module.
I do not feel like you.
I feel more along aspect oriented principles:
Logging is an aspect, highly application dependent,
relevant across module boundaries.
It should *NOT* be embedded into the low level modules
but attached via aspects (if aspect orientation is supported)
or be provided by high level wrappers.
> or not, then each
>of us will need to build a layer around the modules used, in order to
>get things the way he needs... which is what we're already doing...
When I read this I get the impression that this were difficult.
But, it fact, it is trivial.
Here is a wrapper, we use to provide standard handling of
a few exceptions (to be used with Zope). An even simpler wrapper could handle
logging:
class _PostgresAccessCursor(object):
_cursor = None
def __init__(self, da):
C = self._conn = da()
C._register()
self._cursor = C._cursor()
def wrap(f):
def wrapped(self, *args, **kw):
try: return f(self, *args, **kw)
except (psycopg.ProgrammingError,psycopg.IntegrityError), perr:
if 'concurrent update' in perr.args[0]:
raise PostgresTransactionalError('Postgres conflict', perr)
raise
except (psycopg.OperationalError,psycopg.InterfaceError), perr:
C = self._conn
C.close(); C.connect(C.connection)
raise PostgresTransactionalError('Postgres operational error', perr)
return wrapped
@wrap
def execute(self, *args, **kw):
return self._cursor.execute(*args, **kw)
@wrap
def executemany(self, *args, **kw):
return self._cursor.executemany(*args, **kw)
def __getattr__(self, key): return getattr(self._cursor, key)
del wrap
--
Dieter
_______________________________________________
DB-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/db-sig