b51a1f
From c961ee1d7c1abb2552b79ed39ed7fd1bd1b3962f Mon Sep 17 00:00:00 2001
b51a1f
From: srijan-sivakumar <ssivakum@redhat.com>
b51a1f
Date: Fri, 7 Aug 2020 15:02:07 +0530
b51a1f
Subject: [PATCH 487/511] Events: Log file not re-opened after logrotate.
b51a1f
b51a1f
Issue: The logging is being done in the same file
b51a1f
even after the logrotate utility has changed the file.
b51a1f
This causes the logfile to grow indefinitely.
b51a1f
b51a1f
Code Changes: Using the WatchedFileHandler class instead
b51a1f
of FileHandler class. This watches the file it is logging
b51a1f
into and if the file changes, it is closed and reopened
b51a1f
using the file name. Hence after file rotate, a new file
b51a1f
will be used for logging instead of continuing with
b51a1f
the same old file.
b51a1f
b51a1f
>Fixes: #1289
b51a1f
>Change-Id: I773d04f17613a03709cb682692efb39fd8e664e2
b51a1f
>Signed-off-by: srijan-sivakumar <ssivakum@redhat.com>
b51a1f
Upstream Patch : https://review.gluster.org/c/glusterfs/+/24820
b51a1f
b51a1f
BUG: 1814744
b51a1f
Change-Id: I773d04f17613a03709cb682692efb39fd8e664e2
b51a1f
Signed-off-by: srijan-sivakumar <ssivakum@redhat.com>
b51a1f
Reviewed-on: https://code.engineering.redhat.com/gerrit/220370
b51a1f
Reviewed-by: Shwetha Acharya <sacharya@redhat.com>
b51a1f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
b51a1f
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
b51a1f
---
b51a1f
 events/src/utils.py | 3 ++-
b51a1f
 1 file changed, 2 insertions(+), 1 deletion(-)
b51a1f
b51a1f
diff --git a/events/src/utils.py b/events/src/utils.py
b51a1f
index 38b707a..6d4e079 100644
b51a1f
--- a/events/src/utils.py
b51a1f
+++ b/events/src/utils.py
b51a1f
@@ -13,6 +13,7 @@ import sys
b51a1f
 import json
b51a1f
 import os
b51a1f
 import logging
b51a1f
+import logging.handlers
b51a1f
 import fcntl
b51a1f
 from errno import EBADF
b51a1f
 from threading import Thread
b51a1f
@@ -98,7 +99,7 @@ def setup_logger():
b51a1f
     logger.setLevel(logging.INFO)
b51a1f
 
b51a1f
     # create the logging file handler
b51a1f
-    fh = logging.FileHandler(LOG_FILE)
b51a1f
+    fh = logging.handlers.WatchedFileHandler(LOG_FILE)
b51a1f
 
b51a1f
     formatter = logging.Formatter("[%(asctime)s] %(levelname)s "
b51a1f
                                   "[%(module)s - %(lineno)s:%(funcName)s] "
b51a1f
-- 
b51a1f
1.8.3.1
b51a1f