Changing TimeStamper `key` to `"ts"` breaks ordering of logs for ConsoleRenderer
macintacos opened this issue · comments
The following code:
import structlog
structlog.configure(
processors=[
structlog.processors.TimeStamper(fmt="iso", key="ts"),
structlog.stdlib.add_log_level,
structlog.dev.ConsoleRenderer(),
],
logger_factory=structlog.PrintLoggerFactory(),
)
logger = structlog.get_logger()
logger.info("Testing!")
Produces the following logs. Note that ts
is at the end, instead of the beginning, where I would've expected.
[info ] Testing! ts=2023-08-18T21:53:56.587146Z
If I remove the key
parameter from the TimeStamper (structlog.processors.TimeStamper(fmt="iso")
), the timestamp properly moves to the beginning, as I would expect:
2023-08-18T21:54:50.018921Z [info ] Testing!
Considering that the key
parameter is built-into TimeStamper
, could ConsoleRenderer
be updated to properly render the timestamp where it's supposed to be if you change the key
?
I'm also not completely convinced I'm not just doing something wrong, so any help would be appreciated. Thanks!
I suspect we need to add a “timestamp” argument to ConsoleLogger, like we have for renamed “event”
Just curious - if I were to attempt a fix for this, are you planning a release anytime soon?
I will try to get out a soonish release