From 7a2194e6c0c392ea50fb8b325acb27f8a98428f9 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 1 Oct 2006 23:15:53 +0000 Subject: - added profiling to massave - adjusted the formatting for per-instance loggers to limit the number of loggers that get created in memory. --- lib/sqlalchemy/logging.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/logging.py') diff --git a/lib/sqlalchemy/logging.py b/lib/sqlalchemy/logging.py index bba1e0764..bbd008dac 100644 --- a/lib/sqlalchemy/logging.py +++ b/lib/sqlalchemy/logging.py @@ -40,8 +40,10 @@ def default_logging(): handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(name)s %(message)s')) rootlogger.addHandler(handler) -def _get_instance_name(instance): - return instance.__class__.__module__ + "." + instance.__class__.__name__ + "." + hex(id(instance)) +def _get_instance_name(instance): + # since getLogger() does not have any way of removing logger objects from memory, + # instance logging displays the instance id as a modulus of 10 to prevent endless memory growth + return instance.__class__.__module__ + "." + instance.__class__.__name__ + ".0x.." + hex(id(instance))[-2:] def instance_logger(instance): return logging.getLogger(_get_instance_name(instance)) -- cgit v1.2.1