openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
814 B

5 years ago
#!/usr/bin/env python3
import zmq
import cereal.messaging as messaging
from common.logging_extra import SwagLogFileFormatter
from selfdrive.swaglog import get_file_handler
5 years ago
def main():
log_handler = get_file_handler()
log_handler.setFormatter(SwagLogFileFormatter(None))
log_level = 20 # logging.INFO
5 years ago
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)
5 years ago
# then we publish them
msg = messaging.new_message()
msg.logMessage = record
5 years ago
pub_sock.send(msg.to_bytes())
5 years ago
if __name__ == "__main__":
main()