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

agent: Ensure logger set up method is public. #24886

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions command/agent/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,11 @@ func (c *Command) IsValidConfig(config, cmdConfig *Config) bool {
return true
}

// setupLoggers is used to set up the logGate and our logOutput.
func setupLoggers(ui cli.Ui, config *Config) (*gatedwriter.Writer, io.Writer) {
// SetupLoggers is used to set up the logGate and our logOutput.
//
// The function needs to be public due to the way it is used within the Nomad
// Enterprise codebase.
func SetupLoggers(ui cli.Ui, config *Config) (*gatedwriter.Writer, io.Writer) {

// Pull the log level from the configuration, ensure it is titled and then
// perform validation. Do this before the gated writer, as this can
Expand Down Expand Up @@ -801,7 +804,7 @@ func (c *Command) Run(args []string) int {
}

// Set up the log outputs.
logGate, logOutput := setupLoggers(c.Ui, config)
logGate, logOutput := SetupLoggers(c.Ui, config)
if logGate == nil {
return 1
}
Expand Down
4 changes: 2 additions & 2 deletions command/agent/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ func Test_setupLoggers_logFile(t *testing.T) {
}

// Generate the loggers and ensure the correct error is generated.
gatedWriter, writer := setupLoggers(mockUI, cfg)
gatedWriter, writer := SetupLoggers(mockUI, cfg)
must.Nil(t, gatedWriter)
must.Nil(t, writer)
must.StrContains(t, mockUI.ErrorWriter.String(), "Invalid log level: WARNING")
Expand All @@ -650,7 +650,7 @@ func Test_setupLoggers_logFile(t *testing.T) {
// Update the log level, so that it is a valid option and set up the
// loggers again.
cfg.LogLevel = "warn"
gatedWriter, writer = setupLoggers(mockUI, cfg)
gatedWriter, writer = SetupLoggers(mockUI, cfg)
must.NotNil(t, gatedWriter)
must.NotNil(t, writer)

Expand Down
Loading