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