Skip to content

Commit 0c4af5c

Browse files
committed
Updated watch utility
1 parent 1b18412 commit 0c4af5c

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

neo4j/util.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,8 @@
1919
# limitations under the License.
2020

2121

22-
from __future__ import unicode_literals
23-
2422
import logging
25-
from argparse import ArgumentParser
26-
from json import loads as json_loads
27-
from sys import stdout, stderr
28-
29-
from .v1.session import GraphDatabase, CypherError
23+
from sys import stdout
3024

3125

3226
class ColourFormatter(logging.Formatter):
@@ -50,7 +44,7 @@ def format(self, record):
5044

5145

5246
class Watcher(object):
53-
""" Log watcher for debug output.
47+
""" Log watcher for monitoring driver and protocol activity.
5448
"""
5549

5650
handlers = {}
@@ -74,3 +68,16 @@ def stop(self):
7468
self.logger.removeHandler(self.handlers[self.logger_name])
7569
except KeyError:
7670
pass
71+
72+
73+
def watch(logger_name, level=logging.INFO, out=stdout):
74+
""" Quick wrapper for using the Watcher.
75+
76+
:param logger_name: name of logger to watch
77+
:param level: minimum log level to show (default INFO)
78+
:param out: where to send output (default stdout)
79+
:return: Watcher instance
80+
"""
81+
watcher = Watcher(logger_name)
82+
watcher.watch(level, out)
83+
return watcher

0 commit comments

Comments
 (0)