From 6ccfdb79c7779f9eedeea73a21df694551c9893e Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Tue, 21 Jul 2020 23:38:18 +0200 Subject: libutil/logging: extend `internal-json` logger to make it more machine-readable The new error-format is pretty nice from a UX point-of-view, however it's fairly hard to parse the output e.g. for editor plugins such as vim-ale[1] that use `nix-instantiate --parse` to determine syntax errors in Nix expression files. This patch extends the `internal-json` logger by adding the fields `line`, `column` and `file` to easily locate an error in a file and the field `raw_msg` which contains the error-message itself without code-lines and additional helpers. An exemplary output may look like this: ``` [nix-shell]$ ./inst/bin/nix-instantiate ~/test.nix --log-format minimal {"action":"msg","column":1,"file":"/home/ma27/test.nix","level":0,"line":4,"raw_msg":"syntax error, unexpected IF, expecting $end","msg":""} ``` [1] https://github.com/dense-analysis/ale --- doc/manual/command-ref/opt-common.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/manual/command-ref/opt-common.xml b/doc/manual/command-ref/opt-common.xml index a68eef1d0..093bc2526 100644 --- a/doc/manual/command-ref/opt-common.xml +++ b/doc/manual/command-ref/opt-common.xml @@ -106,7 +106,14 @@ internal-json - Outputs the logs in a structured manner. NOTE: the json schema is not guarantees to be stable between releases. + + Outputs the logs in a structured manner. + + + While the schema itself is relatively stable, the format of the error-messages (namely of the msg-field) can change between several releases. + + + bar -- cgit v1.2.3