-
Notifications
You must be signed in to change notification settings - Fork 111
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
RSDK-9752: Add -log-file to viam-server. #4716
Conversation
@@ -70,6 +71,9 @@ func logViamEnvVariables(logger logging.Logger) { | |||
if value, exists := os.LookupEnv("VIAM_MODULE_STARTUP_TIMEOUT"); exists { | |||
viamEnvVariables = append(viamEnvVariables, "VIAM_MODULE_STARTUP_TIMEOUT", value) | |||
} | |||
if value, exists := os.LookupEnv("CWD"); exists { |
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.
A drive-by while I was editting entrypoint.go
Inspired by https://viam.atlassian.net/browse/DOCS-3383
web/server/entrypoint.go
Outdated
logger.SetLevel(logging.INFO) | ||
if argsParsed.OutputLogFile != "" { | ||
logWriter, closer := logging.NewFileAppender(argsParsed.OutputLogFile) | ||
defer closer.Close() |
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.
This lumberjack library spawns a goroutine that it does not wait on when exiting. Despite this call to close.
I talked with @cheukt and we're cool with just disabling leak detection in goutils for ContextualMain
(e.g: viam-server and presumably viam-cli). It'll still run for tests.
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.
SGTM too.
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 % missing comment.
logging/appender.go
Outdated
@@ -36,6 +37,26 @@ func NewWriterAppender(writer io.Writer) ConsoleAppender { | |||
return ConsoleAppender{writer} | |||
} | |||
|
|||
// NewFileAppender will create an Appender that writes output to a log file. Log rotation will be | |||
// enabled such that restarts of the viam-server with the same filename will move the old file out | |||
// of the way. The `io.Closer` |
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.
// of the way. The `io.Closer` | |
// of the way. The `io.Closer` can be used to eventually close the opened log file. |
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.
Also clever way to minimize the methods devs can call on the *lumberjack.Logger
.
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.
Thanks for spotting the unfinished sentence -- added by hand
web/server/entrypoint.go
Outdated
logger.SetLevel(logging.INFO) | ||
if argsParsed.OutputLogFile != "" { | ||
logWriter, closer := logging.NewFileAppender(argsParsed.OutputLogFile) | ||
defer closer.Close() |
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.
SGTM too.
No description provided.