diff options
author | elie <elie> | 2013-03-15 18:40:33 +0000 |
---|---|---|
committer | elie <elie> | 2013-03-15 18:40:33 +0000 |
commit | 989a6dbe7394ff8276bc8a8e7c9d8dacddadc495 (patch) | |
tree | 5c7a1c63c4bf165ebac33c3825ef2a5f5846141b /pysnmp/debug.py | |
parent | daad78aa25b58229a687a6a7e3c41557336f7907 (diff) | |
download | pysnmp-989a6dbe7394ff8276bc8a8e7c9d8dacddadc495.tar.gz |
timestamps to log messages added
Diffstat (limited to 'pysnmp/debug.py')
-rw-r--r-- | pysnmp/debug.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pysnmp/debug.py b/pysnmp/debug.py index 8d75b84..ab00286 100644 --- a/pysnmp/debug.py +++ b/pysnmp/debug.py @@ -1,4 +1,5 @@ import sys +import time from pyasn1.compat.octets import octs2ints from pysnmp import error from pysnmp import __version__ @@ -54,7 +55,7 @@ class Debug: return 'logger %s, flags %x' % (self._printer, self._flags) def __call__(self, msg): - self._printer('DBG: %s\n' % msg) + self._printer('DBG: [%s]: %s\n' % (self.timestamp(), msg)) def __and__(self, flag): return self._flags & flag @@ -62,6 +63,10 @@ class Debug: def __rand__(self, flag): return flag & self._flags + def timestamp(self): + return time.strftime('%H:%M:%S', time.localtime()) + \ + '.%s' % int((time.time() % 1) * 1000) + # This will yield false from bitwise and with a flag, and save # on unnecessary calls logger = 0 |