Commit ffa13567 authored by S. Lackner's avatar S. Lackner

[sched] event logging to files is now optional

parent 6e489b7a
......@@ -215,14 +215,17 @@ class Scheduler(metaclass=ABCMeta):
self._options = options
debug = self.options.get("debug", False)
export_prefix = self.options.get("export-prefix", "out")
write_events = bool(self.options.get("write-events", False))
# Create the logger
self._logger = Logger(self, debug=debug)
self._event_logger = EventLogger(
self, "Events", debug=debug, to_file="{}_last_events.csv".format(
self._event_logger = None
if write_events:
self._event_logger = EventLogger(
self, "Events", debug=debug,
self._sched_jobs_logger = EventLogger(
......@@ -449,28 +452,38 @@ class Scheduler(metaclass=ABCMeta):
def debug(self, msg, **kwargs):
"""Writes a debug message to the logging facility."""
self._logger.debug(self._format_log_msg(msg, **kwargs)), msg, **kwargs))
event = self._format_event_msg(1, msg, **kwargs)
if self._event_logger:
def info(self, msg, **kwargs):
"""Writes a info message to the logging facility.""", **kwargs)), msg, **kwargs))
event = self._format_event_msg(2, msg, **kwargs)
if self._event_logger:
def warn(self, msg, **kwargs):
"""Writes a warn message to the logging facility."""
self._logger.warn(self._format_log_msg(msg, **kwargs)), msg, **kwargs))
event = self._format_event_msg(3, msg, **kwargs)
if self._event_logger:
def error(self, msg, **kwargs):
"""Writes a error message to the logging facility."""
self._logger.error(self._format_log_msg(msg, **kwargs)), msg, **kwargs))
event = self._format_event_msg(4, msg, **kwargs)
if self._event_logger:
def fatal(self, msg, **kwargs):
"""Writes a fatal message to the logging facility and terminates the scheduler."""
error_msg = self._format_log_msg(msg, **kwargs)
self._logger.error(error_msg), msg, **kwargs))
event = self._format_event_msg(5, msg, **kwargs)
if self._event_logger:
raise ValueError("Fatal error: {}".format(error_msg))
def _on_pre_init(self):
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment