mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 03:03:57 +08:00
* log to file and send through athena * rename logging level * pass thru log formatter * logMessage is TEXT * send queue always strings * switch to xattr and lower priority queue * enable cloud logging for devices * time or size based log rotation * basename -> dirname * remove HARDWARE.get_cloudlog_enabled * fix errors * fix another exception * xattrs need to be bytes * sending works * cleanup files at start * add id and adjust formatting * do not send active log file * better names * separate log formatters * fix formatter super init * fix log file order * ensure file always has file formatter * i see why there was no formatter * apply same formatting to cpp log msgs * apply same formatting to cpp log msgs * update queue names in tests * strip deprecated keys in STATUS_PACKET * strip DEPRECATED from dict recursively * athena log queue test * instanceof instead of type * isinstance instead of type * use super * remove logentries * last_scan param unused * comment about special log msg attr names * add dict_helpers.py to release files * use monotonic time and counter for log rotation * update for adjusted log file naming * use monotonic clock for tracking last log file scan
35 lines
814 B
Python
Executable File
35 lines
814 B
Python
Executable File
#!/usr/bin/env python3
|
|
import zmq
|
|
import cereal.messaging as messaging
|
|
from common.logging_extra import SwagLogFileFormatter
|
|
from selfdrive.swaglog import get_file_handler
|
|
|
|
|
|
def main():
|
|
log_handler = get_file_handler()
|
|
log_handler.setFormatter(SwagLogFileFormatter(None))
|
|
log_level = 20 # logging.INFO
|
|
|
|
ctx = zmq.Context().instance()
|
|
sock = ctx.socket(zmq.PULL)
|
|
sock.bind("ipc:///tmp/logmessage")
|
|
|
|
# and we publish them
|
|
pub_sock = messaging.pub_sock('logMessage')
|
|
|
|
while True:
|
|
dat = b''.join(sock.recv_multipart())
|
|
level = dat[0]
|
|
record = dat[1:].decode("utf-8")
|
|
if level >= log_level:
|
|
log_handler.emit(record)
|
|
|
|
# then we publish them
|
|
msg = messaging.new_message()
|
|
msg.logMessage = record
|
|
pub_sock.send(msg.to_bytes())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|