mirror of
https://github.com/esphome/esphome.git
synced 2025-09-13 08:42:18 +01:00
[core] Add millisecond precision to logging timestamps (#10677)
This commit is contained in:
@@ -226,7 +226,9 @@ def run_miniterm(config: ConfigType, port: str, args) -> int:
|
|||||||
.replace(b"\n", b"")
|
.replace(b"\n", b"")
|
||||||
.decode("utf8", "backslashreplace")
|
.decode("utf8", "backslashreplace")
|
||||||
)
|
)
|
||||||
time_str = datetime.now().time().strftime("[%H:%M:%S]")
|
time_ = datetime.now()
|
||||||
|
nanoseconds = time_.microsecond // 1000
|
||||||
|
time_str = f"[{time_.hour:02}:{time_.minute:02}:{time_.second:02}.{nanoseconds:03}]"
|
||||||
safe_print(parser.parse_line(line, time_str))
|
safe_print(parser.parse_line(line, time_str))
|
||||||
|
|
||||||
backtrace_state = platformio_api.process_stacktrace(
|
backtrace_state = platformio_api.process_stacktrace(
|
||||||
|
@@ -62,9 +62,11 @@ async def async_run_logs(config: dict[str, Any], addresses: list[str]) -> None:
|
|||||||
time_ = datetime.now()
|
time_ = datetime.now()
|
||||||
message: bytes = msg.message
|
message: bytes = msg.message
|
||||||
text = message.decode("utf8", "backslashreplace")
|
text = message.decode("utf8", "backslashreplace")
|
||||||
for parsed_msg in parse_log_message(
|
nanoseconds = time_.microsecond // 1000
|
||||||
text, f"[{time_.hour:02}:{time_.minute:02}:{time_.second:02}]"
|
timestamp = (
|
||||||
):
|
f"[{time_.hour:02}:{time_.minute:02}:{time_.second:02}.{nanoseconds:03}]"
|
||||||
|
)
|
||||||
|
for parsed_msg in parse_log_message(text, timestamp):
|
||||||
print(parsed_msg.replace("\033", "\\033") if dashboard else parsed_msg)
|
print(parsed_msg.replace("\033", "\\033") if dashboard else parsed_msg)
|
||||||
|
|
||||||
stop = await async_run(cli, on_log, name=name)
|
stop = await async_run(cli, on_log, name=name)
|
||||||
|
Reference in New Issue
Block a user