Skip to content

Commit

Permalink
MNT: Update elastic index
Browse files Browse the repository at this point in the history
  • Loading branch information
ke-zhang-rd committed Mar 14, 2019
1 parent a0169b9 commit 6bd6648
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions nslsii/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from IPython import get_ipython
from ._version import get_versions
import .loggers import configure_elastic
__version__ = get_versions()['version']
del get_versions

Expand Down Expand Up @@ -148,6 +149,9 @@ def configure_base(user_ns, broker_name, *,
ch.setLevel(logging.ERROR)
ophyd.ophydobj.logger.addHandler(ch)

configure_elastic(broker_name)
#Configure elastic log handler including bluesky, carproto and ophyd

# convenience imports
# some of the * imports are for 'back-compatibility' of a sort -- we have
# taught BL staff to expect LiveTable and LivePlot etc. to be in their
Expand Down
18 changes: 11 additions & 7 deletions nslsii/loggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ def emit(self, record):
except Exception:
self.handleError(record)

def configure_elastic(beamline):
url = 'http://elasticsearch.cs.nsls2.local/' + beamline + '.blueksy'

bluesky_logger = logging.getLogger('bluesky')
carproto_logger = logging.getLogger('carproto')
ophyd_logger = logging.getLogger('ophyd')
bluesky_logger = logging.getLogger('bluesky')
bluesky_elastic_hdr = ElasticHandler(url, level = logging.DEBUG)
bluesky_logger.addHandler(elastic_hdr)

elastic_hdr = ElasticHandler('http://elasticsearch.cs.nsls2.local/test/_doc/1')
carproto_logger = logging.getLogger('carproto')
carproto_elastic_hdr = ElasticHandler(url, level = logging.INFO)
carproto_logger.addHandler(elastic_hdr)

bluesky_logger.addHandler(elastic_hdr)
carproto_logger.addHandler(elastic_hdr)
ophyd_logger.addHandler(elastic_hdr)
ophyd_logger = logging.getLogger('ophyd')
ophyd_elastic_hdr = ElasticHandler(url, level = logging.INFO)
ophyd_logger.addHandler(elastic_hdr)

0 comments on commit 6bd6648

Please sign in to comment.