NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
11.91k stars 1.46k forks source link

C API: Logging callbacks #11036

Open ehmry opened 1 month ago

ehmry commented 1 month ago

It would be ideal to have isolated logging streams that would be associated with either an evaluator state, or store, or a context. By logs I mean output from builtins.trace and from builders.

At the moment it would be a nice feature for me but if I find I really need it then I might attempt to implement it myself.

Priorities

Add :+1: to issues you find important.

roberth commented 1 month ago

Nix has a global logger, and it could provide a C API function to set it.

https://github.com/NixOS/nix/blob/509be0e77aacd8afcf419526620994cbbbe3708a/src/libutil/logging.hh#L183

This allows intercepting almost all output; certainly build logs and builtins.trace and friends.

Child process stderr (e.g. git clone) isn't always captured, but that probably isn't too much of a problem for most applications.

nixos-discourse commented 1 month ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-07-10-nix-team-meeting-minutes-160/49101/1