summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/logging.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-08-21 23:06:12 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-08-21 23:06:12 +0000
commitf9e4af9830cfa116a0a8ed863059b85d8977a27b (patch)
treee088e35458f2ba4bd3d22269ad4972e85eaea6c0 /lib/sqlalchemy/logging.py
parentfba14f6047341f1fa07413e1507c9649614766c5 (diff)
downloadsqlalchemy-f9e4af9830cfa116a0a8ed863059b85d8977a27b.tar.gz
-removed echo_property() function, moved logging checks to
static variables
Diffstat (limited to 'lib/sqlalchemy/logging.py')
-rw-r--r--lib/sqlalchemy/logging.py38
1 files changed, 11 insertions, 27 deletions
diff --git a/lib/sqlalchemy/logging.py b/lib/sqlalchemy/logging.py
index 17f89c7d2..2dfd1e50a 100644
--- a/lib/sqlalchemy/logging.py
+++ b/lib/sqlalchemy/logging.py
@@ -56,9 +56,6 @@ def _get_instance_name(instance):
# also speeds performance as logger initialization is apparently slow
return instance.__class__.__module__ + "." + instance.__class__.__name__ + ".0x.." + hex(id(instance))[-2:]
-def instance_logger(instance):
- return logging.getLogger(_get_instance_name(instance))
-
def class_logger(cls):
return logging.getLogger(cls.__module__ + "." + cls.__name__)
@@ -68,27 +65,14 @@ def is_debug_enabled(logger):
def is_info_enabled(logger):
return logger.isEnabledFor(logging.INFO)
-class echo_property(object):
- level_map={logging.DEBUG : "debug", logging.INFO:True}
-
- __doc__ = """when ``True``, enable log output for this element.
-
- This has the effect of setting the Python logging level for the
- namespace of this element's class and object reference. A value
- of boolean ``True`` indicates that the loglevel ``logging.INFO`` will be
- set for the logger, whereas the string value ``debug`` will set the loglevel
- to ``logging.DEBUG``.
- """
-
- def __get__(self, instance, owner):
- if instance is None:
- return self
- level = logging.getLogger(_get_instance_name(instance)).getEffectiveLevel()
- return echo_property.level_map.get(level, False)
-
- def __set__(self, instance, value):
- if value:
- default_logging(_get_instance_name(instance))
- logging.getLogger(_get_instance_name(instance)).setLevel(value == 'debug' and logging.DEBUG or logging.INFO)
- else:
- logging.getLogger(_get_instance_name(instance)).setLevel(logging.NOTSET)
+def instance_logger(instance, echoflag=None):
+ if echoflag:
+ default_logging(_get_instance_name(instance))
+ l = logging.getLogger(_get_instance_name(instance))
+ l.setLevel(echoflag == 'debug' and logging.DEBUG or logging.INFO)
+ else:
+ l = logging.getLogger(_get_instance_name(instance))
+ instance._should_log_debug = l.isEnabledFor(logging.DEBUG)
+ instance._should_log_info = l.isEnabledFor(logging.INFO)
+ return l
+ \ No newline at end of file