From 4d63f723c02ec5e5e7b27fc3993fcac512122498 Mon Sep 17 00:00:00 2001 From: Daniel Blanchard Date: Mon, 14 Jul 2014 12:56:55 -0400 Subject: [PATCH 1/7] See if pypy works now --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2cc92864..b09e8232 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: python python: - "2.7" - "3.3" + - "pypy" install: - "pip install -r requirements.txt" From 04d776c961dedd36d4bdbae75eed58ce91441941 Mon Sep 17 00:00:00 2001 From: Daniel Blanchard Date: Mon, 14 Jul 2014 13:05:46 -0400 Subject: [PATCH 2/7] Revert "See if pypy works now" This reverts commit 4d63f723c02ec5e5e7b27fc3993fcac512122498. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b09e8232..2cc92864 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: python python: - "2.7" - "3.3" - - "pypy" install: - "pip install -r requirements.txt" From 02813a988f1128f2bcc9c7918037ff048d0cef14 Mon Sep 17 00:00:00 2001 From: Daniel Blanchard Date: Tue, 15 Jul 2014 14:31:27 -0400 Subject: [PATCH 3/7] Add modules to __init__.py so tab completion works in ipython --- streamparse/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/streamparse/__init__.py b/streamparse/__init__.py index a286a396..7fb7266c 100644 --- a/streamparse/__init__.py +++ b/streamparse/__init__.py @@ -6,7 +6,15 @@ from __future__ import absolute_import, print_function, unicode_literals -from .version import __version__, VERSION +import streamparse.base +import streamparse.bolt +import streamparse.cmdln +import streamparse.contextmanagers +import streamparse.debug +import streamparse.decorators +import streamparse.ipc +import streamparse.spout +from streamparse.version import __version__, VERSION __license__ = """ Copyright 2014 Parsely, Inc. From 43d5c880182edfe524a1f5655c1f25b17a36e57c Mon Sep 17 00:00:00 2001 From: Daniel Blanchard Date: Sat, 19 Jul 2014 20:30:05 -0400 Subject: [PATCH 4/7] Remove unnecessary module-level variables from ipc.py --- streamparse/ipc.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/streamparse/ipc.py b/streamparse/ipc.py index cd32aa9a..2c4fa450 100644 --- a/streamparse/ipc.py +++ b/streamparse/ipc.py @@ -16,9 +16,6 @@ from six import PY3 -config = context = None -storm_log = logging.getLogger('streamparse') - _MAX_MESSAGE_SIZE = 16777216 _MAX_BLANK_MSGS = 500 _MAX_LINES = 100 @@ -161,6 +158,7 @@ def read_tuple(): def read_handshake(): """Read and process an initial handshake message from Storm.""" + storm_log = logging.getLogger('streamparse') # Redirect stdout and stderr to ensure that print statements/functions # won't crash the Storm Java worker sys.stdout = LogStream(logging.getLogger('streamparse.stdout')) From 33271b323dde0fd07d247da34e6d4634ac941715 Mon Sep 17 00:00:00 2001 From: Daniel Blanchard Date: Wed, 27 Aug 2014 16:22:48 -0400 Subject: [PATCH 5/7] Add StormHandler to simplify switching betweeen Storm and Python logging --- streamparse/base.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/streamparse/base.py b/streamparse/base.py index ff8aff45..c976a86e 100644 --- a/streamparse/base.py +++ b/streamparse/base.py @@ -1,6 +1,7 @@ """Base primititve classes for working with Storm.""" from __future__ import absolute_import, print_function, unicode_literals +from logging import Handler from traceback import format_exc from .ipc import send_message @@ -20,6 +21,30 @@ } +class StormHandler(Handler): + """Handler that will send messages back to Storm.""" + + def __init__(self): + """ Initialize handler """ + Handler.__init__(self) + + def emit(self, record): + """ + Emit a record. + + If a formatter is specified, it is used to format the record. + If exception information is present, it is formatted using + traceback.print_exception and sent to Storm. + """ + try: + msg = self.format(record) + level = _STORM_LOG_LEVELS.get(record.levelname.upper(), + _STORM_LOG_INFO) + send_message({'command': 'log', 'msg': str(msg), 'level': level}) + except Exception: + self.handleError(record) + + class Component(object): """Base class for Spouts and Bolts which contains class methods for logging messages back to the Storm worker process.""" From 010adb78f33ddc280972d1af9b4ac5e072dccc3e Mon Sep 17 00:00:00 2001 From: Daniel Blanchard Date: Wed, 27 Aug 2014 16:23:27 -0400 Subject: [PATCH 6/7] Fix upper/lower mix-up --- streamparse/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/streamparse/base.py b/streamparse/base.py index c976a86e..0dac6425 100644 --- a/streamparse/base.py +++ b/streamparse/base.py @@ -38,7 +38,7 @@ def emit(self, record): """ try: msg = self.format(record) - level = _STORM_LOG_LEVELS.get(record.levelname.upper(), + level = _STORM_LOG_LEVELS.get(record.levelname.lower(), _STORM_LOG_INFO) send_message({'command': 'log', 'msg': str(msg), 'level': level}) except Exception: From a53afd51d1d21ecd79cfb9437fdd3ce2d5b252c2 Mon Sep 17 00:00:00 2001 From: Daniel Blanchard Date: Wed, 27 Aug 2014 16:25:06 -0400 Subject: [PATCH 7/7] Support warning and warn as names for logging level to be consistent with Python logging --- streamparse/base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/streamparse/base.py b/streamparse/base.py index 0dac6425..fb2c568f 100644 --- a/streamparse/base.py +++ b/streamparse/base.py @@ -17,6 +17,7 @@ 'debug': _STORM_LOG_DEBUG, 'info': _STORM_LOG_INFO, 'warn': _STORM_LOG_WARN, + 'warning': _STORM_LOG_WARN, 'error': _STORM_LOG_ERROR, }