Skip to content
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

Merged
merged 6 commits into from
Jan 16, 2025

Conversation

dgottlieb
Copy link
Member

No description provided.

@dgottlieb dgottlieb requested a review from benjirewis January 15, 2025 20:06
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Jan 15, 2025
@@ -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 {
Copy link
Member Author

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

logger.SetLevel(logging.INFO)
if argsParsed.OutputLogFile != "" {
logWriter, closer := logging.NewFileAppender(argsParsed.OutputLogFile)
defer closer.Close()
Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM too.

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 15, 2025
Copy link
Member

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % missing comment.

@@ -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`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// of the way. The `io.Closer`
// of the way. The `io.Closer` can be used to eventually close the opened log file.

Copy link
Member

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.

Copy link
Member Author

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

logger.SetLevel(logging.INFO)
if argsParsed.OutputLogFile != "" {
logWriter, closer := logging.NewFileAppender(argsParsed.OutputLogFile)
defer closer.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM too.

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 15, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 15, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 16, 2025
@dgottlieb dgottlieb merged commit c90ee46 into viamrobotics:main Jan 16, 2025
16 checks passed
@dgottlieb dgottlieb deleted the RSDK-9752-rotation branch January 16, 2025 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants