Commit graph

22 commits

Author SHA1 Message Date
Eelco Dolstra e27044216b Fix tests 2020-12-22 16:23:57 +01:00
Maximilian Bosch 6ccfdb79c7
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":"<full error-msg with code-lines etc>"}
```

[1] https://github.com/dense-analysis/ale
2020-07-26 02:29:57 +02:00
Ben Burdette 75bfcf8d15 revamp trace code and test 2020-07-06 10:51:48 -06:00
Ben Burdette bf2788e4c1 move showTrace to new loggerSettings 2020-07-02 09:04:31 -06:00
Ben Burdette 8497891b99 spacing 2020-07-01 13:50:18 -06:00
Ben Burdette 2a39c083dc non-pos trace test 2020-07-01 10:37:31 -06:00
Ben Burdette a7d5d26443 fix tests with the 'from string' change 2020-06-30 22:05:21 -06:00
Ben Burdette ddb81ca126 Merge branch 'master' into add-trace 2020-06-30 12:21:45 -06:00
Ben Burdette a0705e0dd1 invalid pos check 2020-06-30 11:01:46 -06:00
Ben Burdette 8f81fae116 showTrace flag in loggers 2020-06-29 10:20:51 -06:00
Ben Burdette 9ab808c926 showTrace flag for ErrorInfo; showTrace test. 2020-06-25 09:23:12 -06:00
Ben Burdette 9c0e1fd4f1 add trace test; error formatting refinements 2020-06-24 18:31:28 -06:00
Ben Burdette 1d43a6e123 use plain errPos instead of nixCode; fix tests 2020-06-23 15:30:13 -06:00
Ben Burdette d0e78fbb03 re-add Pos origin in tests 2020-06-23 10:51:58 -06:00
Ben Burdette 9d1cb0c5e6 with normaltxt, elide yellow color code instead of canceling it; use normaltxt on plain_string hintfmt 2020-06-22 11:32:20 -06:00
Ben Burdette be4f444175 tidying up 2020-06-19 16:58:12 -06:00
Ben Burdette 0309488a66 fmt -> hintfmt test 2020-06-19 16:46:49 -06:00
Ben Burdette db475f9e7e too few, too many args 2020-06-19 15:28:13 -06:00
Ben Burdette cdddf24f25 add hintfmt test 2020-06-19 14:54:41 -06:00
Tobias Pflug cd8214c398 Fix logging unit tests 2020-06-16 10:23:15 +02:00
Ben Burdette 94c347577e set verbosity levels 2020-06-07 07:24:49 -06:00
Tobias Pflug 952e72c804 Add tests for logging.hh 2020-06-06 10:22:32 +02:00