Skip to content

Commit

Permalink
Logging to elk
Browse files Browse the repository at this point in the history
  • Loading branch information
osher-stratoscale committed Jun 4, 2018
1 parent a9958fd commit 05f98d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions py/strato/common/log/configurelogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
_name = None
_registered_file_handles = dict()


def logFilename(name):
return '%s/%s%s' % (config.LOGS_DIRECTORY, name, config.LOGS_SUFFIX)

Expand Down Expand Up @@ -60,6 +61,14 @@ def configureLogger(loggerName):
outputFilename = "%s__%s" % (_name, loggerName)
_configureOutputToFile(logging.getLogger(loggerName), outputFilename)

from py.strato.tests.monitors import loggerconfig
log=loggerconfig.LogStashLogger(loggerName="_logs", messageType="_logs", verbose=False)

_log = log.getLogger()
_log.setLevel(logging.INFO)

logging.root.addHandler(_log)


def addFileHandler(name, path):
fileHandler = logging.FileHandler(filename=path)
Expand Down
3 changes: 3 additions & 0 deletions py/strato/common/log/machinereadableformatter.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import simplejson
import uuid


class MachineReadableFormatter:
_IGNORED_ATTRIBUTES = set(['relativeCreated', 'msecs', 'message', 'exc_info', 'startColor', 'endColor'])
session_id = uuid.uuid4()

def format(self, record):
record.session_id = str(self.session_id)
data = dict(record.__dict__)
for attribute in self._IGNORED_ATTRIBUTES:
if attribute in data:
Expand Down

0 comments on commit 05f98d3

Please sign in to comment.