-
Notifications
You must be signed in to change notification settings - Fork 26
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
Support logging to file #558
Conversation
I think the main drawback I see with this is that if you want to have the output match the other switches (e.g. write JSON instead of text lines when But now @dryajov has two options to choose from. 😁 |
If we swapped the newly added (index 2) |
This would work, but it would also mean we'd now have two different ways to get JSON output depending on whether it's to stdout or to a file. It could also violate the principle of least surprise as people seeing the And I'm also somewhat unclear on this (not sure how these |
Yes, it would need a recompile for the changes to take effect, however they wouldn't compile because the properties of a json Chronicles output are different than a dynamic textlines output, and as such, In my opinion, end users shouldn't (or wouldn't) be swapping these Chronicles options out in config.nims (which simply serves as cli flags during Codex compilation) as end users will use a Codex binary and its own cli flags, eg |
fwiw, we're looking to remove this option from nimbus-eth2, instead guiding users to log-rotating redirection tools (ie |
I did bring this up, @arnetheduck, but the concern that got raised was that we need to support environments where such tools might not be available (e.g. Windows). Though in all honesty I don't think anyone of us bothered to check if Windows had a tee equivalent, which it apparently does (https://superuser.com/questions/74127/tee-for-windows). |
c877150
to
6e5f5b4
Compare
codex/codex.nim
Outdated
@@ -129,7 +129,7 @@ proc bootstrapInteractions( | |||
return (client, host, validator) | |||
|
|||
proc start*(s: CodexServer) {.async.} = | |||
notice "Starting codex node" | |||
notice "Starting codex node", config = $s.config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this printing the entire config object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, perhaps we can add a separate trace/debug
that prints it. It's very useful for debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, this could be useful info for the user. We can always downgrade the log level later if we dislike it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can get somewhat large tho, maybe trace
is more appropriate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not too bad, and shows default values that were not specified by the user. But i can change it to trace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This seems to make our life easier right now, tho I agree that we're probably better off using tee/logrotate
in prod, this seems useful for debugging in some scenarios.
6e5f5b4
to
ea2c611
Compare
f06812e
to
bc9c522
Compare
Closes #554.
As in #554, this supports logging to a file, however in this PR, it is accomplished via a dynamic Chronicle's sink. The reason for a dynamic sink (
textlines[dynamic]
) is so that file logging can be disabled, because Chronicles' default behavior fortextlines[file]
is to log to a default file.The main drawback, as discussed in #554 is that the file is not closed, which is no better than Chronicles. I did attempt to return the opened file from
setupLogging
and subsequently close it (on SIGINT and SIGTERM), however Chronicles continues to log past these events, so handling of file close would need to come after Chronicles is done with it (I'm not entirely sure if this is doable).