Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion py/strato/common/log/configurelogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ def configureLogging(name, forceDirectory=None, registerConfigurationReloadSigna
hostname = subprocess.check_output('/bin/hostname').strip()
if registerConfigurationReloadSignal:
_configureLoggingSignalHandlers()
if os.environ.get("MONKEY_ELASTIFY"):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where do you check it is Monkey who called the configureLogging?
i think not only monkey uses pycommonlog

logging.info('Passing monkey logs to elk')
from py.strato.tests.monitors.loggerconfig import LogStashLogger
log = LogStashLogger(loggerName="monkey-logs", messageType="monkey-logs", verbose=False)
_log = log.getLogger()
_log.setLevel(logging.INFO)
logging .root.addHandler(_log)
logging.info("Logging started for '%(name)s' on '%(hostname)s'", dict(
name=name, hostname=hostname))

Expand All @@ -60,7 +67,6 @@ def configureLogger(loggerName):
outputFilename = "%s__%s" % (_name, loggerName)
_configureOutputToFile(logging.getLogger(loggerName), outputFilename)


def addFileHandler(name, path):
fileHandler = logging.FileHandler(filename=path)
formatter = logging.Formatter(
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()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every monkey test already has a UUID - can we reuse it?


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