mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-26 15:30:18 +00:00
Added log output control options
This commit is contained in:
parent
40cd961eab
commit
47db2a3bd5
@ -61,6 +61,7 @@ loglevel = LOG_NOTICE
|
|||||||
logfile = None
|
logfile = None
|
||||||
logdest = LOG_STDOUT
|
logdest = LOG_STDOUT
|
||||||
logtimefmt = "%Y-%m-%d %H:%M:%S"
|
logtimefmt = "%Y-%m-%d %H:%M:%S"
|
||||||
|
compact_log_fmt = False
|
||||||
|
|
||||||
instance_random = random.Random()
|
instance_random = random.Random()
|
||||||
instance_random.seed(os.urandom(10))
|
instance_random.seed(os.urandom(10))
|
||||||
@ -101,10 +102,14 @@ def timestamp_str(time_s):
|
|||||||
return time.strftime(logtimefmt, timestamp)
|
return time.strftime(logtimefmt, timestamp)
|
||||||
|
|
||||||
def log(msg, level=3, _override_destination = False):
|
def log(msg, level=3, _override_destination = False):
|
||||||
global _always_override_destination
|
global _always_override_destination, compact_log_fmt
|
||||||
|
|
||||||
if loglevel >= level:
|
if loglevel >= level:
|
||||||
|
if not compact_log_fmt:
|
||||||
logstring = "["+timestamp_str(time.time())+"] ["+loglevelname(level)+"] "+msg
|
logstring = "["+timestamp_str(time.time())+"] ["+loglevelname(level)+"] "+msg
|
||||||
|
else:
|
||||||
|
logstring = "["+timestamp_str(time.time())+"] "+msg
|
||||||
|
|
||||||
logging_lock.acquire()
|
logging_lock.acquire()
|
||||||
|
|
||||||
if (logdest == LOG_STDOUT or _always_override_destination or _override_destination):
|
if (logdest == LOG_STDOUT or _always_override_destination or _override_destination):
|
||||||
|
Loading…
Reference in New Issue
Block a user