aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/logging.cc
AgeCommit message (Collapse)Author
2021-07-01Respect TERM=dumb more consistentlyYestin L. Harrison
2021-01-21Improve error formattingEelco Dolstra
Changes: * The divider lines are gone. These were in practice a bit confusing, in particular with --show-trace or --keep-going, since then there were multiple lines, suggesting a start/end which wasn't the case. * Instead, multi-line error messages are now indented to align with the prefix (e.g. "error: "). * The 'description' field is gone since we weren't really using it. * 'hint' is renamed to 'msg' since it really wasn't a hint. * The error is now printed *before* the location info. * The 'name' field is no longer printed since most of the time it wasn't very useful since it was just the name of the exception (like EvalError). Ideally in the future this would be a unique, easily googleable error ID (like rustc). * "trace:" is now just "…". This assumes error contexts start with something like "while doing X". Example before: error: --- AssertionError ---------------------------------------------------------------------------------------- nix at: (7:7) in file: /home/eelco/Dev/nixpkgs/pkgs/applications/misc/hello/default.nix 6| 7| x = assert false; 1; | ^ 8| assertion 'false' failed ----------------------------------------------------- show-trace ----------------------------------------------------- trace: while evaluating the attribute 'x' of the derivation 'hello-2.10' at: (192:11) in file: /home/eelco/Dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix 191| // (lib.optionalAttrs (!(attrs ? name) && attrs ? pname && attrs ? version)) { 192| name = "${attrs.pname}-${attrs.version}"; | ^ 193| } // (lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform && !dontAddHostSuffix && (attrs ? name || (attrs ? pname && attrs ? version)))) { Example after: error: assertion 'false' failed at: (7:7) in file: /home/eelco/Dev/nixpkgs/pkgs/applications/misc/hello/default.nix 6| 7| x = assert false; 1; | ^ 8| … while evaluating the attribute 'x' of the derivation 'hello-2.10' at: (192:11) in file: /home/eelco/Dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix 191| // (lib.optionalAttrs (!(attrs ? name) && attrs ? pname && attrs ? version)) { 192| name = "${attrs.pname}-${attrs.version}"; | ^ 193| } // (lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform && !dontAddHostSuffix && (attrs ? name || (attrs ? pname && attrs ? version)))) {
2020-10-28Capitalize JSON for consistencyMatthew Kenigsberg
2020-10-06Remove static variable name clashesEelco Dolstra
This was useful for an experiment with building Nix as a single compilation unit. It's not very useful otherwise but also doesn't hurt...
2020-07-26libutil/logging: extend `internal-json` logger to make it more machine-readableMaximilian Bosch
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-08Fix 'got unknown message type 1 from Nix daemon'Eelco Dolstra
Example: $ nix-build -E 'with import <nixpkgs> {}; runCommand "foo" { x = runCommand "bar" {} "exit 1"; } "echo foo; exit 1"' warning: unknown setting 'auto-allocate-uids' these 2 derivations will be built: /nix/store/v4fbdbhcdi949929a67g8farwf72zgam-bar.drv /nix/store/k4fsvrjl7cp2xpz7927iv7g0dqj1zyhs-foo.drv warning: unknown setting 'auto-allocate-uids' building '/nix/store/v4fbdbhcdi949929a67g8farwf72zgam-bar.drv'... error: --- Error ----------------------------------------------------------------------------------------------------------------------------------------------------------------- nix-daemon builder for '/nix/store/v4fbdbhcdi949929a67g8farwf72zgam-bar.drv' failed with exit code 1 error: --- Error ------------------------------------------------------------------------------------------------------------------------------------------------------------------ nix-build got unknown message type 1 from Nix daemon
2020-07-02move showTrace to new loggerSettingsBen Burdette
2020-07-01non-pos trace testBen Burdette
2020-06-30comments and cleanupBen Burdette
2020-06-29showTrace flag in loggersBen Burdette
2020-06-15Remove trailing whitespaceEelco Dolstra
2020-06-11Merge remote-tracking branch 'upstream/master' into errors-phase-2Ben Burdette
2020-06-08Unify the printing of the logs between bar-with-logs and rawregnat
Make the printing of the build logs systematically go through the logger, and replicate the behavior of `no-build-output` by having two different loggers (one that prints the build logs and one that doesn't)
2020-06-08Make the logger customisableregnat
Add a new `--log-format` cli argument to change the format of the logs. The possible values are - raw (the default one for old-style commands) - bar (the default one for new-style commands) - bar-with-logs (equivalent to `--print-build-logs`) - internal-json (the internal machine-readable json format)
2020-06-02elide the 'ErrorInfo' in logError and logWarning callsBen Burdette
2020-05-13change status messages to info levelBen Burdette
2020-05-12remove unused extra json fieldsBen Burdette
2020-05-11Merge branch 'master' into errors-phase-2Ben Burdette
2020-05-08add pos to errorinfo, remove from hintsBen Burdette
2020-05-06Revert "Merge pull request #3558 from LnL7/ssh-ng-stderr"Eelco Dolstra
This reverts commit 3ebfbecdd187002569257f7cb183bf9e0b39af1e, reversing changes made to c089c52d5f1cff888552f485775b74226dcbe618. https://github.com/NixOS/nix/pull/3558
2020-05-02logging: handle build log lines in simple loggerDaiderd Jordan
The raw stderr output isn't logged anymore so the build logs need to be printed by the default logger in order for the old commands like nix-build to still show build output.
2020-04-29uncrustify formattingBen Burdette
2020-04-17demoing other error levels than warn/error; rename line and file fields in ↵Ben Burdette
errPos
2020-04-17logError, logWarning; Logger functions; switch to Verbosity enumBen Burdette
2020-04-16Logger: Add method for writing to stdoutEelco Dolstra
Usually this just writes to stdout, but for ProgressBar, we need to clear the current line, write the line to stdout, and then redraw the progress bar. (cherry picked from commit 696c026006a6ac46adc990ed5cb0f31535bac076)
2020-04-08DataTransfer -> FileTransferNikola Knezevic
2020-04-08actDownload -> actDataTransferNikola Knezevic
2020-02-01Show "warning:" in yellow instead of redEelco Dolstra
2019-06-25Add "warning" verbosity levelEelco Dolstra
This ensures that "nix" shows warnings. Previously these were hidden because they were at "info" level. (cherry picked from commit 615a9d031d22a6aee64f8511e15685e47b6f8796)
2018-03-15Filter ANSI colors when not writing to a terminalEelco Dolstra
Fixes https://github.com/NixOS/nixpkgs/issues/37114.
2018-03-12Wrap thread local in function for CygwinAsad Saeeduddin
Fixes #1826. See #1352 for a previous instance of a similar change.
2018-03-06logging: Don't throw from Activity destructorWill Dietz
Move definition of destructor to logging.cc for access to util.hh's ignoreException.
2018-02-07Improve filtering of ANSI escape sequences in build logsEelco Dolstra
All ANSI sequences except color setting are now filtered out. In particular, terminal resets (such as from NixOS VM tests) are filtered out. Also, fix the completely broken tab character handling.
2017-12-11logging.cc: add missing 'override'Will Dietz
2017-10-24More progress indicator improvementsEelco Dolstra
Fixes #1599.
2017-10-24Handle log messages from build-remoteEelco Dolstra
This makes the progress indicator show statuses like "connecting to 'root@machine'".
2017-08-28Give activities a verbosity level againEelco Dolstra
And print them (separately from the progress bar) given sufficient -v flags.
2017-08-25Allow activities to be nestedEelco Dolstra
In particular, this allows more relevant activities ("substituting X") to supersede inferior ones ("downloading X").
2017-08-25Restore activity metadataEelco Dolstra
This allows the progress bar to display "building perl-5.22.3" instead of "building /nix/store/<hash>-perl-5.22.3.drv".
2017-08-16Progress indicator: CleanupEelco Dolstra
2017-08-16Progress indicator: Show number of active itemsEelco Dolstra
2017-08-16nix copy: Improve progress indicatorEelco Dolstra
It now shows the amount of data copied: [8/1038 copied, 160.4/1590.9 MiB copied] copying path '...'
2017-08-16nix copy: Revive progress barEelco Dolstra
2017-05-29Fix build failure on Debian/UbuntuEelco Dolstra
http://hydra.nixos.org/build/53537463
2017-05-16Improve progress indicatorEelco Dolstra
2017-04-13Add warn functionEelco Dolstra
2017-04-13Initialise loggerEelco Dolstra
2016-09-21printMsg(lvlError, ...) -> printError(...) etc.Eelco Dolstra
2016-09-16printMsg(): Don't check for interruptsEelco Dolstra
Having the logger function potentially throw exceptions is Heisenbuggy.
2016-04-25Improved logging abstractionEelco Dolstra
This also gets rid of --log-type, since the nested log type isn't useful in a multi-threaded situation, and nobody cares about the "pretty" log type.