Page MenuHomePhabricator

Add key-value support to LogPrint
Open, Needs TriagePublic

Description

key-value logging makes it easy to log data more complex than single-values. This can be emulated with the current LogPrint function by calling it multiple times, but this produces unclean output with differing timestamps. I propose to use JSON for key-value logging, as it's human-readable as well as interpretable by other applications.

The current log format is something like: 2018-02-04 22:55:01 Bitcoin ABC version v0.16.3.0-4fee9ec

I propose that we migrate all logs to the new JSON format, in which it would make more sense to format it as follows:

{
    "timestamp": "2018-02-04 22:55:01",
    "key1": "value1",
    "key2": "value2",
    "key3": "value3",
}

Logs that do not explicitly require key-value mapping can default to "message" as the key, so the above current log format would be output as:

{
    "timestamp": "2018-02-04 22:55:01",
    "message": "Bitcoin ABC version v0.16.3.0-4fee9ec"
}

Related Objects