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