Reputation: 6732
I see different ways to use Structlog and I was wondering what the exact difference is.
Let's say I want to log something using Structlog, you could for example use:
logger.msg("My log message")
But there are other ways to log, like info, debug (as in the standard Python logging library) which give you the possibility to say something about the importance of a message (which you can filter using loglevel):
logger.info("This is an info message")
logger.debug("This is a debug message")
The question is: what is the advantage of using logger.msg as compared to the other ways to log like info and debug? Why would I choose logger.msg?
Upvotes: 1
Views: 534
Reputation: 4126
msg()
is a remnant from the original generic BoundLogger that tried to have both stdlib and Twisted log methods (msg()
hailing from the Twisted end).
If you use structlog's internal filtering system via structlog.make_filtering_bound_logger()
, it's equivalent to the info
log level.
You can safely ignore it.
Upvotes: 1