mirror of
https://github.com/Kozea/Radicale.git
synced 2025-06-26 16:45:52 +00:00
Include time in log messages
This commit is contained in:
parent
180e96b332
commit
6b46b01fcb
1 changed files with 5 additions and 3 deletions
|
@ -39,7 +39,8 @@ except ImportError:
|
|||
systemd = None
|
||||
|
||||
LOGGER_NAME = "radicale"
|
||||
LOGGER_FORMAT = "[%(ident)s] %(levelname)s: %(message)s"
|
||||
LOGGER_FORMAT = "[%(asctime)s] [%(ident)s] [%(levelname)s] %(message)s"
|
||||
DATE_FORMAT = "%Y-%m-%d %H:%M:%S %z"
|
||||
|
||||
logger = logging.getLogger(LOGGER_NAME)
|
||||
|
||||
|
@ -61,7 +62,7 @@ class IdentLogRecordFactory:
|
|||
|
||||
def __call__(self, *args, **kwargs):
|
||||
record = self.upstream_factory(*args, **kwargs)
|
||||
ident = "%x" % os.getpid()
|
||||
ident = "%d" % os.getpid()
|
||||
main_thread = threading.main_thread()
|
||||
current_thread = threading.current_thread()
|
||||
if current_thread.name and main_thread != current_thread:
|
||||
|
@ -135,7 +136,8 @@ def setup():
|
|||
"""Set global logging up."""
|
||||
global register_stream
|
||||
handler = ThreadStreamsHandler(sys.stderr, get_default_handler())
|
||||
logging.basicConfig(format=LOGGER_FORMAT, handlers=[handler])
|
||||
logging.basicConfig(format=LOGGER_FORMAT, datefmt=DATE_FORMAT,
|
||||
handlers=[handler])
|
||||
register_stream = handler.register_stream
|
||||
log_record_factory = IdentLogRecordFactory(logging.getLogRecordFactory())
|
||||
logging.setLogRecordFactory(log_record_factory)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue