Skip to content

Commit

Permalink
Log Recod logging with new characterstic
Browse files Browse the repository at this point in the history
  • Loading branch information
thebentern committed Jul 1, 2024
1 parent d5a4d86 commit bef9b48
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions meshtastic/ble_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,22 @@ def from_num_handler(self, _, b): # pylint: disable=C0116
self.should_read = True

async def log_radio_handler(self, _, b): # pylint: disable=C0116
if b is not mesh_pb2.LogRecord:
return
log_record = mesh_pb2.LogRecord()
log_record.ParseFromString(bytes(b))
log_record.message.replace("\n", "")

message = f'[{log_record.source}] {log_record.message}' if log_record.source else log_record.message

log_record = b
if log_record.DEBUG:
print_color.print(log_record.message, color="cyan", end=None)
print_color.print(message, color="cyan", end=None)
elif log_record.INFO:
print_color.print(log_record.message, color="white", end=None)
print_color.print(message, color="white", end=None)
elif log_record.WARNING:
print_color.print(log_record.message, color="yellow", end=None)
print_color.print(message, color="yellow", end=None)
elif log_record.ERROR:
print_color.print(log_record.message, color="red", end=None)
print_color.print(message, color="red", end=None)
else:
print_color.print(log_record.message, end=None)
print_color.print(message, end=None)

async def legacy_log_radio_handler(self, _, b): # pylint: disable=C0116
log_radio = b.decode("utf-8").replace("\n", "")
Expand Down

0 comments on commit bef9b48

Please sign in to comment.