summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-10-31 20:25:33 -0600
committerJason Gerard DeRose <jderose@redhat.com>2008-10-31 20:25:33 -0600
commit242a8183a7cc002f496421352e8346db4232648b (patch)
tree23f83463b766af467a631af5c6a8b54973ccf5d6
parent5e5a83e4e84d2e9a5d6d987056199a8ed83978b8 (diff)
downloadfreeipa-242a8183a7cc002f496421352e8346db4232648b.tar.gz
freeipa-242a8183a7cc002f496421352e8346db4232648b.tar.xz
freeipa-242a8183a7cc002f496421352e8346db4232648b.zip
Added custom log formatter util.LogFormatter that makes the human-readable time stamp in UTC
-rw-r--r--ipalib/constants.py4
-rw-r--r--ipalib/plugable.py4
-rw-r--r--ipalib/util.py9
3 files changed, 13 insertions, 4 deletions
diff --git a/ipalib/constants.py b/ipalib/constants.py
index 7b0e1661..99b0ea71 100644
--- a/ipalib/constants.py
+++ b/ipalib/constants.py
@@ -45,8 +45,8 @@ LOG_FORMAT_STDERR_DEBUG = ' '.join([
# Tab-delimited log format for file (easy to opened in a spreadsheet):
-LOG_FORMAT_FILE = ' '.join([
- '%(created)f',
+LOG_FORMAT_FILE = '\t'.join([
+ '%(asctime)s',
'%(levelname)s',
'%(message)r', # Using %r for repr() so message is a single line
'%(lineno)d',
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 64a9d835..08a978ed 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -793,7 +793,7 @@ class API(DictProxy):
stderr.setLevel(logging.INFO)
else:
stderr.setLevel(logging.WARNING)
- stderr.setFormatter(logging.Formatter(format))
+ stderr.setFormatter(util.LogFormatter(format))
log.addHandler(stderr)
# Add file handler:
@@ -807,7 +807,7 @@ class API(DictProxy):
log.warn('Could not create log_dir %r', log_dir)
return
handler = logging.FileHandler(self.env.log)
- handler.setFormatter(logging.Formatter(self.env.log_format_file))
+ handler.setFormatter(util.LogFormatter(self.env.log_format_file))
if self.env.debug:
handler.setLevel(logging.DEBUG)
else:
diff --git a/ipalib/util.py b/ipalib/util.py
index c1652065..12f9c781 100644
--- a/ipalib/util.py
+++ b/ipalib/util.py
@@ -25,6 +25,8 @@ import os
from os import path
import imp
import optparse
+import logging
+import time
import krbV
@@ -122,3 +124,10 @@ def add_global_options(parser=None):
help='Produce more verbose output',
)
return parser
+
+
+class LogFormatter(logging.Formatter):
+ """
+ Log formatter that uses UTC for all timestamps.
+ """
+ converter = time.gmtime