https://fedorahosted.org/freeipa/ticket/5757


Patches attached.

From a76d63aea17b3b429defd059a026b2764e92e5b7 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Wed, 29 Jun 2016 13:34:19 +0200
Subject: [PATCH 1/2] Enhance logger to allow logfiles with timestamps

Keyword '{timestamp}' in logfile will be automatically replaced with
date and time in format "%Y%m%d%H%M"

Required for: https://fedorahosted.org/freeipa/ticket/5757
---
 ipapython/ipa_log_manager.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ipapython/ipa_log_manager.py b/ipapython/ipa_log_manager.py
index 8a555ebda7919214c20d40ec45b9b5f7863f0298..4471b7f13ab83726f7f927dc82d77c5dcd596694 100644
--- a/ipapython/ipa_log_manager.py
+++ b/ipapython/ipa_log_manager.py
@@ -29,6 +29,8 @@ import sys
 import re
 import copy
 
+from datetime import datetime
+
 from ipapython.log_manager import LogManager, parse_log_level
 
 #-------------------------------------------------------------------------------
@@ -62,6 +64,8 @@ LOGGING_FORMAT_STANDARD_CONSOLE = '%(name)-12s: %(levelname)-8s %(message)s'
 # Used by standard_logging_setup() for file message
 LOGGING_FORMAT_STANDARD_FILE = '%(asctime)s %(levelname)s %(message)s'
 
+FILENAME_TIMESTAMP_FORMAT = '%Y%m%d%H%M'
+
 #-------------------------------------------------------------------------------
 
 class IPALogManager(LogManager):
@@ -177,6 +181,8 @@ def standard_logging_setup(filename=None, verbose=False, debug=False,
 
     # File output is always logged at debug level
     if filename is not None:
+        filename = filename.format(
+            timestamp = datetime.now().strftime(FILENAME_TIMESTAMP_FORMAT))
         file_handler = dict(name='file',
                             filename=filename,
                             filemode=filemode,
-- 
2.5.5

From 678ffbdbda2b776c6f8edcc513b6fd3674067fc3 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Wed, 29 Jun 2016 14:28:33 +0200
Subject: [PATCH 2/2] Use timestamps for ipa-replica-conncheck with timestamps

ipareplica-conncheck log file is used under different SELinux context
depending on if it called locally or remotely via oddjob. We need
to separate logfiles with different contexts and the best way according
the future plans is to use timestamps for logfiles.

https://fedorahosted.org/freeipa/ticket/5757
---
 ipaplatform/base/paths.py          | 2 +-
 ipatests/test_integration/tasks.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ipaplatform/base/paths.py b/ipaplatform/base/paths.py
index d6fbe32f6839a5db40148777132ba1454cbc3382..2b76faf487cf39f641adad1b7ca8ea0119d73eef 100644
--- a/ipaplatform/base/paths.py
+++ b/ipaplatform/base/paths.py
@@ -304,7 +304,7 @@ class BasePathNamespace(object):
     IPACLIENT_INSTALL_LOG = "/var/log/ipaclient-install.log"
     IPACLIENT_UNINSTALL_LOG = "/var/log/ipaclient-uninstall.log"
     IPAREPLICA_CA_INSTALL_LOG = "/var/log/ipareplica-ca-install.log"
-    IPAREPLICA_CONNCHECK_LOG = "/var/log/ipareplica-conncheck.log"
+    IPAREPLICA_CONNCHECK_LOG = "/var/log/ipareplica-conncheck-{timestamp}.log"
     IPAREPLICA_INSTALL_LOG = "/var/log/ipareplica-install.log"
     IPARESTORE_LOG = "/var/log/iparestore.log"
     IPASERVER_CA_INSTALL_LOG = "/var/log/ipaserver-ca-install.log"
diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py
index 38218fa709c2c220d5fea98a092b55e995d48d77..373fb637aec051e9086f11e9ec51dcf4bab13e4d 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -322,7 +322,7 @@ def install_replica(master, replica, setup_ca=True, setup_dns=False,
         domain_level = domainlevel(master)
     apply_common_fixes(replica)
     replica.collect_log(paths.IPAREPLICA_INSTALL_LOG)
-    replica.collect_log(paths.IPAREPLICA_CONNCHECK_LOG)
+    replica.collect_log(paths.IPAREPLICA_CONNCHECK_LOG.format(timestamp='*'))
     allow_sync_ptr(master)
     # Otherwise ipa-client-install would not create a PTR
     # and replica installation would fail
-- 
2.5.5

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to