summaryrefslogtreecommitdiff
path: root/pyasn1/debug.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyasn1/debug.py')
-rw-r--r--pyasn1/debug.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/pyasn1/debug.py b/pyasn1/debug.py
index 9a79f20..9b69886 100644
--- a/pyasn1/debug.py
+++ b/pyasn1/debug.py
@@ -32,6 +32,14 @@ class Printer:
def __call__(self, msg): self.__logger.debug(msg)
def __str__(self): return '<python built-in logging>'
+if hasattr(logging, 'NullHandler'):
+ NullHandler = logging.NullHandler
+else:
+ # Python 2.6 and older
+ class NullHandler(logging.Handler):
+ def emit(self, record):
+ pass
+
class Debug:
defaultPrinter = None
def __init__(self, *flags, **options):
@@ -44,7 +52,7 @@ class Debug:
# route our logs to parent logger
self._printer = Printer(
logger=logging.getLogger(options['loggerName']),
- handler=logging.NullHandler()
+ handler=NullHandler()
)
else:
self._printer = Printer()