avi
avi

Reputation: 9636

How do I make Python Structlog to log without the keyword `event`

I am using Python Structlog. Everything is logged as

event='Something Happened'

I don't want that event keyword and I just want the event data to be logged:

'Something happened'

How do I achieve this?

Upvotes: 0

Views: 1791

Answers (1)

hynek
hynek

Reputation: 4126

You can always write an own renderer that just logs out the event without anything else:

>>> def renderer(logger, name, event_dict):
...     return event_dict["event"]
...
>>> import structlog
>>> structlog.configure(processors=[renderer])
>>> structlog.get_logger().msg("look, no struct!")
look, no struct!

Upvotes: 1

Related Questions