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

release log gate if disable-gated-logs flag is set #24280

Merged
merged 4 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions changelog/24280.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
command/server: release log gate if disable-gated-logs flag is set
hghaf099 marked this conversation as resolved.
Show resolved Hide resolved
```
5 changes: 5 additions & 0 deletions command/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ func (c *AgentCommand) Run(args []string) int {
InferLevelsWithTimestamp: true,
})

// release log gate if the disable-gated-logs flag is set
if c.logFlags.flagDisableGatedLogs {
c.logGate.Flush()
}

infoKeys := make([]string, 0, 10)
info := make(map[string]string)
info["log level"] = config.LogLevel
Expand Down
2 changes: 2 additions & 0 deletions command/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ const (
flagNameDisableRedirects = "disable-redirects"
// flagNameCombineLogs is used to specify whether log output should be combined and sent to stdout
flagNameCombineLogs = "combine-logs"
// flagDisableGatedLogs is used to disable gated logs and immediately show the vault logs as they become available
flagDisableGatedLogs = "disable-gated-logs"
// flagNameLogFile is used to specify the path to the log file that Vault should use for logging
flagNameLogFile = "log-file"
// flagNameLogRotateBytes is the flag used to specify the number of bytes a log file should be before it is rotated.
Expand Down
8 changes: 8 additions & 0 deletions command/log_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
// logFlags are the 'log' related flags that can be shared across commands.
type logFlags struct {
flagCombineLogs bool
flagDisableGatedLogs bool
flagLogLevel string
flagLogFormat string
flagLogFile string
Expand All @@ -41,6 +42,13 @@ func (f *FlagSet) addLogFlags(l *logFlags) {
Hidden: true,
})

f.BoolVar(&BoolVar{
Name: flagDisableGatedLogs,
Target: &l.flagDisableGatedLogs,
Default: false,
Hidden: true,
})

f.StringVar(&StringVar{
Name: flagNameLogLevel,
Target: &l.flagLogLevel,
Expand Down
5 changes: 5 additions & 0 deletions command/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ func (c *ProxyCommand) Run(args []string) int {
}
c.logger = l

// release log gate if the disable-gated-logs flag is set
if c.logFlags.flagDisableGatedLogs {
c.logGate.Flush()
}

infoKeys := make([]string, 0, 10)
info := make(map[string]string)
info["log level"] = config.LogLevel
Expand Down
5 changes: 5 additions & 0 deletions command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,11 @@ func (c *ServerCommand) Run(args []string) int {
c.logger = l
c.allLoggers = append(c.allLoggers, l)

// flush logs right away if the server is started with the disable-gated-logs flag
if c.logFlags.flagDisableGatedLogs {
c.flushLog()
}

// reporting Errors found in the config
for _, cErr := range configErrors {
c.logger.Warn(cErr.String())
Expand Down
Loading