summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsrijan-sivakumar <ssivakum@redhat.com>2020-08-07 15:02:07 +0530
committerSunny Kumar <sunkumar@redhat.com>2020-08-11 10:40:22 +0000
commitb759709f947da57e00b44262fa3fa72a53557ca2 (patch)
treec4bf5179d994a6dd4e637cf6251c7d390782adac
parent634ce64d0f03ddf3c2a3c05ce21cf9cdcbb763c5 (diff)
Events: Log file not re-opened after logrotate.
Issue: The logging is being done in the same file even after the logrotate utility has changed the file. This causes the logfile to grow indefinitely. Code Changes: Using the WatchedFileHandler class instead of FileHandler class. This watches the file it is logging into and if the file changes, it is closed and reopened using the file name. Hence after file rotate, a new file will be used for logging instead of continuing with the same old file. Fixes: #1289 Change-Id: I773d04f17613a03709cb682692efb39fd8e664e2 Signed-off-by: srijan-sivakumar <ssivakum@redhat.com>
-rw-r--r--events/src/utils.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/events/src/utils.py b/events/src/utils.py
index 38b707a1b28..6d4e0791a2b 100644
--- a/events/src/utils.py
+++ b/events/src/utils.py
@@ -13,6 +13,7 @@ import sys
import json
import os
import logging
+import logging.handlers
import fcntl
from errno import EBADF
from threading import Thread
@@ -98,7 +99,7 @@ def setup_logger():
logger.setLevel(logging.INFO)
# create the logging file handler
- fh = logging.FileHandler(LOG_FILE)
+ fh = logging.handlers.WatchedFileHandler(LOG_FILE)
formatter = logging.Formatter("[%(asctime)s] %(levelname)s "
"[%(module)s - %(lineno)s:%(funcName)s] "