What is the format of the log?

Hello everyone!

I am logging Home Assistant activity to a syslog server and what I see are records similar to

#033[32m2018-03-20 12:11:30 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sun.sun, old_state=<state sun.sun=above_horizon; next_dawn=2018-03-21T05:21:41+00:00, next_dusk=2018-03-20T18:34:25+00:00, next_midnight=2018-03-20T23:58:41+00:00, next_noon=2018-03-20T11:59:07+00:00, next_rising=2018-03-21T05:53:10+00:00, next_setting=2018-03-20T18:02:57+00:00, elevation=40.19, azimuth=164.1, friendly_name=Sun @ 2018-03-20T10:50:13.703095+01:00>, new_state=<state sun.sun=above_horizon; next_dawn=2018-03-21T05:21:41+00:00, next_dusk=2018-03-20T18:34:25+00:00, next_midnight=2018-03-20T23:58:41+00:00, next_noon=2018-03-20T11:59:07+00:00, next_rising=2018-03-21T05:53:10+00:00, next_setting=2018-03-20T18:02:57+00:00, elevation=40.24, azimuth=164.42, friendly_name=Sun @ 2018-03-20T10:50:13.703095+01:00>>#033[0m

Since I would like to transform it into something more suitable for analysis I was wondering if it follows an established standard (I do not recognize it). It would make it easier to parse it than to jump into regex to cur it apart.

I’m wondering as well!

that’s a state change, and that is standard. While you may not see it, everything from the first < to the last > is a dictionary. Thats going to have a bunch of key value pairs, some values may be a dictionary (denoted with a starting < and ending > as well. You’ll most likely have to use regex to parse that, unless you don’t care about the state changes.

Thank you. It is a shame that the format is not JSON which would have been much easier to handle in a log management engine.

Yeah, i’m not sure why it is that way. My guess is so that it’s less code like for people who don’t code. Or it’s a simple interpreter print statement which is converting everything.

I know I’m late to the discussion …
Have you looked at rsyslog modules that store the logs in different entities? e.g. ELK stacks, databases …
I’ve never done this for HA. There is plenty of documentation on the internet.

It’s kind of pointless because you can access the state changes through normal events. What’s in the log is just… well a log. No need to parse the file when you can just build an event trigger.