Skip to content
This repository has been archived by the owner on Dec 30, 2021. It is now read-only.

Support other backends for logging in the tool #59

Open
ckoparkar opened this issue Aug 15, 2019 · 2 comments
Open

Support other backends for logging in the tool #59

ckoparkar opened this issue Aug 15, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@ckoparkar
Copy link
Contributor

At the moment reverie does have a logger. To use it in a tool, one needs to initialize it with tools_helper::logger::init() and pass an environment variable TOOL_LOG=level to the reverie binary. Then, all the log crate macros like info!, debug! etc log their output to stdout.

It would be really nice if the tool could also log things somewhere other than stdout, to a file for example.

@ckoparkar ckoparkar added the enhancement New feature or request label Aug 15, 2019
@wangbj
Copy link
Collaborator

wangbj commented Aug 15, 2019

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.

@ckoparkar
Copy link
Contributor Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants