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