mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
lvmdbusd: Add date & ts if running in a terminal
When we are running in a terminal it's useful to have a date & ts on log output like you get when output goes to the journal. Check if we are running on a tty and if we are, add it in.
This commit is contained in:
parent
7e37e7fde4
commit
a0a2c84a26
@ -13,6 +13,7 @@ import inspect
|
||||
import ctypes
|
||||
import os
|
||||
import string
|
||||
import datetime
|
||||
|
||||
import dbus
|
||||
import dbus.service
|
||||
@ -243,6 +244,12 @@ def _common_log(msg, *attributes):
|
||||
cfg.stdout_lock.acquire()
|
||||
tid = ctypes.CDLL('libc.so.6').syscall(186)
|
||||
|
||||
if STDOUT_TTY:
|
||||
msg = "%s: %d:%d - %s" % \
|
||||
(datetime.datetime.now().strftime("%b %d %H:%M:%S.%f"),
|
||||
os.getpid(), tid, msg)
|
||||
|
||||
else:
|
||||
msg = "%d:%d - %s" % (os.getpid(), tid, msg)
|
||||
|
||||
if STDOUT_TTY and attributes:
|
||||
|
Loading…
x
Reference in New Issue
Block a user