-
-
Notifications
You must be signed in to change notification settings - Fork 629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging interface #271
Comments
There is some inconsistent logging going on. I haven't settled on a solution I'm happy with. There is use of "log", and "github.com/anacrolix/log", the latter through which I intend to allow python logging-style levels, handlers, formatters etc. If you have any suggestions, or PRs to clean these up, feel free to contribute. |
Sounds good~ I will see what I can do~ |
I also ended up wanting to hide the logs outputted by the program, instead of providing a logger interface and unifying both logging libraries what I endep up doing (good enough for my use-case) was to simply ensure that those You can see an example of how it looks like here, I haven't submitted a pull request as I don't know if this workaround is something that seems ok to you, I'll create it if @anacrolix is ok with it. |
It's always difficult, one man's log is another man's noise. Are there specific log messages that are annoying you? Generally I try to log anything that may indicate degraded performance, or should not occur under favourable conditions. For example the UPnP debug message is difficult, as if UPnP discovery fails, performance may be greatly affected for some users. |
Also note that making the logging system more complicated isn't useful to casual consumers of the library. They have to understand the system to know what to log for their purposes. |
If you want to make a PR with your desired changes, I'm happy to accept many of them. |
Well, my specific scenario was that of a cli utility that uses your library so I just wanted a way to hide all but fatal If |
@anacrolix were you able to check the PR #308? |
@yonson2 Yes, it inspired me to standardize the logging. See the comment in #308. All log messages now route through the Client logger, which isn't yet exposed. |
For now, set os.Stdout = nil and log to file instead Reference: anacrolix/torrent#271
The Client Logger is now exposed, and also supported by the DHT. https://github.com/anacrolix/log has settled into something I'm a bit happier with. |
For posterity, if someone wants to override the log you can look at a use case here -> #551 |
Currently, this library is logging by default which doesn't seem very nice. There are some places where it seems to arbitrarily output logs. This prevents me from being able to do much with them (hide them, output them with a bit of formatting etc). Would it be possible to have the config receive a something like a simple Logger interface or something.
I am not sure where all the places that "log" automatically are but if these are the only spots then it could be something simple like:
Then you would pass something like
log.New(os.Stderr, "", log.LstdFlags)
(same thing as defaultlog
Logger) from default config but the user (of the library) could change out the logging as necessary. I also seeflog
in this same file... are there multiple logging libraries used throughout this project???edit
Ah yes,
flog
orgithub.aaakk.us.kg/anacrolix/log
has essentially the same issue in that same file and outputs things like:2018-08-25 20:12:18 portfwd.go:31: discovered 0 upnp devices
It looks like
flog
has a bit of a different interface =/. Is there any way the logging interface can be simplified and generalized for all logging? The way this is logging doesn't really allow me to make the logs fit the format I would want nor does it let me prevent or redirect all the logging (without interacting outside with stdout).The text was updated successfully, but these errors were encountered: