mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Added custom log formatter util.LogFormatter that makes the human-readable time stamp in UTC
This commit is contained in:
parent
5e5a83e4e8
commit
242a8183a7
@ -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',
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user