Module: check_mk
Branch: master
Commit: a51ca3b59ad56716b5a4ba4e23f7e824fdf8b616
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a51ca3b59ad567…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Feb 27 16:04:06 2018 +0100
Appending to log files instead of overwriting them might be a good idea...
Change-Id: I5d8d16ceb197fc0112830282e865dc9fba92ef9e
---
bin/mkeventd | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/bin/mkeventd b/bin/mkeventd
index c4b0df7..3de7f31 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -925,7 +925,8 @@ def log_event_history_to_file(settings, event, what, who, addinfo):
columns += [quote_tab(event.get(colname[6:], defval)) # drop "event_"
for colname, defval in g_status_server.table_events.columns]
-
get_logfile(settings.paths.history_dir.value).write_bytes("\t".join(map(to_utf8,
columns)) + "\n")
+ with get_logfile(settings.paths.history_dir.value).open(mode='ab') as f:
+ f.write("\t".join(map(to_utf8, columns)) + "\n")
def to_utf8(x):
@@ -2907,12 +2908,13 @@ class EventServer(ECServerThread):
def log_message(self, event):
try:
- get_logfile(self.settings.paths.messages_dir.value).write_bytes("%s %s
%s%s: %s\n" % (
- time.strftime("%b %d %H:%M:%S",
time.localtime(event["time"])),
- event["host"],
- event["application"],
- event["pid"] and ("[%s]" % event["pid"]) or
"",
- event["text"]))
+ with
get_logfile(self.settings.paths.messages_dir.value).open(mode='ab') as f:
+ f.write("%s %s %s%s: %s\n" % (
+ time.strftime("%b %d %H:%M:%S",
time.localtime(event["time"])),
+ event["host"],
+ event["application"],
+ event["pid"] and ("[%s]" %
event["pid"]) or "",
+ event["text"]))
except Exception:
if self.settings.options.debug:
raise