0

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?

Joe
  • 41,484
  • 20
  • 104
  • 125
avi
  • 9,292
  • 11
  • 47
  • 84
  • Why don't you use the `built in logging` given you don't need the `struct` – luoluo Sep 11 '15 at 12:34
  • I use some custom processors for structlog and only at the last step(i.e. writing to file) I don't want `event`. – avi Sep 11 '15 at 12:35

1 Answers1

1

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!
hynek
  • 3,647
  • 1
  • 18
  • 26
  • How do I log to a file with PrintLogger()? – Ali Gajani Jan 06 '17 at 20:43
  • PrintLoggerFactory takes a file argument: http://www.structlog.org/en/stable/api.html#structlog.PrintLoggerFactory – but you should really always print to stdout and redirect it somewhere. That’s much more flexible. – hynek Jan 16 '17 at 09:49