diff options
-rw-r--r-- | ipalib/constants.py | 4 | ||||
-rw-r--r-- | ipalib/plugable.py | 4 | ||||
-rw-r--r-- | ipalib/util.py | 9 |
3 files changed, 13 insertions, 4 deletions
diff --git a/ipalib/constants.py b/ipalib/constants.py index 7b0e1661e..99b0ea719 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 64a9d8354..08a978ed1 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 c16520654..12f9c7814 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 |