Open ckoparkar opened 4 years ago
Thanks for submitting this issue. logging to file should be relatively easy, with one caveat: we probably want allocate a predefined FD number, preferably close to 1024. Because open an fd in the very same memory address space has visible effects to the tracee, for instance, if you just open a log file with fd=3, then the musl build script would fail, because it has bellow script in its configure
:
exec 3>&1 1>config.mak
In short, it expects configure
script to be opened as fd=3, which is true if you run the script directly from shell environment.
Okay. Maybe instead of accepting any Write
handle, the logger could offer a few different options ? For example:
enum LogBackend {
Stdout,
Stderr,
File { path: String },
...
}
fn init(backend: LogBackend) {
....
}
I'm not saying this should the API or anything but with something like this, all the details of how to initialize the bakend are hidden away from the tool and reverie
is free to do the right thing for each of these.
At the moment
reverie
does have a logger. To use it in a tool, one needs to initialize it withtools_helper::logger::init()
and pass an environment variableTOOL_LOG=level
to the reverie binary. Then, all thelog
crate macros likeinfo!
,debug!
etc log their output tostdout
.It would be really nice if the tool could also log things somewhere other than
stdout
, to a file for example.