mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-12-18 18:10:17 +00:00
Added ability to reflect RNS logs to app-internal log handler callback
This commit is contained in:
parent
5e2b3df623
commit
ed30fa3e0a
@ -213,6 +213,9 @@ class Reticulum:
|
|||||||
if logdest == RNS.LOG_FILE:
|
if logdest == RNS.LOG_FILE:
|
||||||
RNS.logdest = RNS.LOG_FILE
|
RNS.logdest = RNS.LOG_FILE
|
||||||
RNS.logfile = Reticulum.configdir+"/logfile"
|
RNS.logfile = Reticulum.configdir+"/logfile"
|
||||||
|
elif callable(logdest):
|
||||||
|
RNS.logdest = RNS.LOG_CALLBACK
|
||||||
|
RNS.logcall = logdest
|
||||||
|
|
||||||
Reticulum.configpath = Reticulum.configdir+"/config"
|
Reticulum.configpath = Reticulum.configdir+"/config"
|
||||||
Reticulum.storagepath = Reticulum.configdir+"/storage"
|
Reticulum.storagepath = Reticulum.configdir+"/storage"
|
||||||
|
@ -59,12 +59,14 @@ LOG_EXTREME = 7
|
|||||||
|
|
||||||
LOG_STDOUT = 0x91
|
LOG_STDOUT = 0x91
|
||||||
LOG_FILE = 0x92
|
LOG_FILE = 0x92
|
||||||
|
LOG_CALLBACK = 0x93
|
||||||
|
|
||||||
LOG_MAXSIZE = 5*1024*1024
|
LOG_MAXSIZE = 5*1024*1024
|
||||||
|
|
||||||
loglevel = LOG_NOTICE
|
loglevel = LOG_NOTICE
|
||||||
logfile = None
|
logfile = None
|
||||||
logdest = LOG_STDOUT
|
logdest = LOG_STDOUT
|
||||||
|
logcall = None
|
||||||
logtimefmt = "%Y-%m-%d %H:%M:%S"
|
logtimefmt = "%Y-%m-%d %H:%M:%S"
|
||||||
compact_log_fmt = False
|
compact_log_fmt = False
|
||||||
|
|
||||||
@ -141,6 +143,17 @@ def log(msg, level=3, _override_destination = False):
|
|||||||
log("Dumping future log events to console!", LOG_CRITICAL)
|
log("Dumping future log events to console!", LOG_CRITICAL)
|
||||||
log(msg, level)
|
log(msg, level)
|
||||||
|
|
||||||
|
elif logdest == LOG_CALLBACK:
|
||||||
|
try:
|
||||||
|
logcall(logstring)
|
||||||
|
logging_lock.release()
|
||||||
|
except Exception as e:
|
||||||
|
logging_lock.release()
|
||||||
|
_always_override_destination = True
|
||||||
|
log("Exception occurred while calling external log handler: "+str(e), LOG_CRITICAL)
|
||||||
|
log("Dumping future log events to console!", LOG_CRITICAL)
|
||||||
|
log(msg, level)
|
||||||
|
|
||||||
|
|
||||||
def rand():
|
def rand():
|
||||||
result = instance_random.random()
|
result = instance_random.random()
|
||||||
|
Loading…
Reference in New Issue
Block a user