Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zmq logging #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pyoperant/behavior/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from pyoperant import ComponentError, InterfaceError
from pyoperant.behavior import shape
import random
import zmq
from zmq.log.handlers import PUBHandler

try:
import simplejson as json
Expand Down Expand Up @@ -101,6 +103,15 @@ def log_config(self):
format='"%(asctime)s","%(levelname)s","%(message)s"')
self.log = logging.getLogger()

# setup ZMQ log handler
ctx = zmq.Context()
pub = ctx.socket(zmq.PUB)
pub.bind('tcp://*:31967')
self.pub_handler = PUBHandler(pub)
self.pub_handler.root_topic = socket.gethostname()
self.log.addHandler(self.pub_handler)


if 'email' in self.parameters['log_handlers']:
from pyoperant.local import SMTP_CONFIG
from logging import handlers
Expand Down