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