-
Notifications
You must be signed in to change notification settings - Fork 49
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
Zap doesn't provide a simple way to add a writer #66
Comments
@lanzafame I guess you need that for |
|
That solves my problem. I will just get that ok'ed by the powers that be. @Stebalien are you ok with the removal of |
Another option would be to allow streaming all logs, which would be much harder (but possible). |
Discussed in-person with @lanzafame: I suggested we keep However, I didn't think that through. So, I've changed my mind. Let's just deprecate this command for now. |
Actually, I take that back. It turns out zap has a nice NewTee function. We can use this to combine two cores: one that's only enabled when If this turns out to be too much work, I'm fine punting. But it doesn't look difficult. |
I think, we would need to forgo the simplified configuration we do with In simplified model (if Cores would be:
The stderr core would write to: MultiWriteSyncer, that would write into stderr and a custom Writer that would either discard or buffer logs for streaming to cli. |
Part of the work to unblock: ipfs/go-log#66 License: MIT Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
Adds one package level function NewPipeReader which returns a reader that can be used to listen into the logging output. Fixes ipfs#66 and allows go-filecoin to implement go-filecoin log tail using v2 of go-log
Another take on ipfs#66 This change introduces a multicore implementation that allows additonal zap cores to be added at runtime. Each core can be configured with distinct encoders and writers which makes it possible to tail the logs in a program using a different log format (e.g. program may log in json but interactive tailing can be in plaintext). This comes at the cost of an additional mutex that must be taken on each write since the destination of the write is mutable. It reworks (and simplifies) the pipe reader implementation added in ipfs#87 and adds a new function NewPipeReaderFormat which creates a pipe reader using a different output format. This change also allows us to reconfigure logging after it has been initialised by swapping out the initial zap core with a newly configured one. This solves the problem that I attempted in ipfs#88 Adds a Config struct to enable easier reconfiguration of the logger. The default config is still read from the environment in init() but a client of the package can now call SetupLogging again with a custom config to adjust logging after initialization. Note that the fix for ipfs#83 is slightly different. If a file is specified using GOLOG_FILE then logging to stderr will be disabled but logging can be configured to write to both file and stderr by calling SetupLogging with the appropriate configuration.
Another take on ipfs#66 This change introduces a multicore implementation that allows additonal zap cores to be added at runtime. Each core can be configured with distinct encoders and writers which makes it possible to tail the logs in a program using a different log format (e.g. program may log in json but interactive tailing can be in plaintext). This comes at the cost of an additional mutex that must be taken on each write since the destination of the write is mutable. It reworks (and simplifies) the pipe reader implementation added in ipfs#87 and adds a new function NewPipeReaderFormat which creates a pipe reader using a different output format. This change also allows us to reconfigure logging after it has been initialised by swapping out the initial zap core with a newly configured one. This solves the problem that I attempted in ipfs#88 Adds a Config struct to enable easier reconfiguration of the logger. The default config is still read from the environment in init() but a client of the package can now call SetupLogging again with a custom config to adjust logging after initialization. Note that the fix for ipfs#83 is slightly different. If a file is specified using GOLOG_FILE then logging to stderr will be disabled but logging can be configured to write to both file and stderr by calling SetupLogging with the appropriate configuration.
Looking at moving go-ipfs to #65 's version of go-log, and one of the sticking points is converting the functionality of the
writer.WriterGroup.AddWriter
call. Zap provides a way to redirect to another logger with a way of undoing the redirection or to add another SyncWriter or you can open a new output but that requires the output have a URL... I shall come back to this issue once I have dug into it more.The text was updated successfully, but these errors were encountered: