Radish alpha
r
rad:zwTxygwuz5LDGBq255RA2CbNGrz8
Radicle CI broker
Radicle
Git
feat: use the tracing crate for structured logging
Merged liw opened 1 year ago

Switch from the “slog” family of crates for structured logging to the “tracing” family. There should be no significant changes to the log messages, so I don’t consider this to be a breaking change.

The benefit of this change is that it opens up the possibility to add extra fields to the log messages as JSON values, instead of strings that contain the values as JSON.

With slog we currently have this message::

{“msg”:“broker database: /home/_rad/ci-broker.db”}

With slog or tracing we can change this to:

{“msg”:“open database”, “filename”: “/home/_rad/ci-broker.db”}

With tracing we can have this:

{“msg”:“open database”,“db”:{“type”:“sqlite”,“filename”:“/home/_rad/ci-broker.db”,“size”:12765}}

which would be, formatted prettily

{ “msg”: “open database”, “db”: { “type”: “sqlite”, “filename”: “/home/_rad/ci-broker.db”, “size”: 12765 } }

Such extra fields can then be easily queried or otherwise processed with programs, much more easily than having such programs parse text fields as JSON before they can be processed.

Doing this with slog is supposed to be possible, but I have failed to get it to work. The slog and tracing families of libraries seem otherwise similar for our purposes.

Signed-off-by: Lars Wirzenius liw@liw.fi

liw opened with revision 050212ce on base 84cfab01 +161 -310 1 year ago

Switch from the “slog” family of crates for structured logging to the “tracing” family. There should be no significant changes to the log messages, so I don’t consider this to be a breaking change.

The benefit of this change is that it opens up the possibility to add extra fields to the log messages as JSON values, instead of strings that contain the values as JSON.

With slog we currently have this message::

{“msg”:“broker database: /home/_rad/ci-broker.db”}

With slog or tracing we can change this to:

{“msg”:“open database”, “filename”: “/home/_rad/ci-broker.db”}

With tracing we can have this:

{“msg”:“open database”,“db”:{“type”:“sqlite”,“filename”:“/home/_rad/ci-broker.db”,“size”:12765}}

which would be, formatted prettily

{ “msg”: “open database”, “db”: { “type”: “sqlite”, “filename”: “/home/_rad/ci-broker.db”, “size”: 12765 } }

Such extra fields can then be easily queried or otherwise processed with programs, much more easily than having such programs parse text fields as JSON before they can be processed.

Doing this with slog is supposed to be possible, but I have failed to get it to work. The slog and tracing families of libraries seem otherwise similar for our purposes.

Signed-off-by: Lars Wirzenius liw@liw.fi

liw merged revision 050212ce at cf395350 1 year ago