mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-30 18:17:55 +00:00 
			
		
		
		
	backport of commit 57b6b74283 (#24470)
				
					
				
			Co-authored-by: Hamid Ghaf <83242695+hghaf099@users.noreply.github.com>
This commit is contained in:
		 hc-github-team-secure-vault-core
					hc-github-team-secure-vault-core
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							90443ec6ed
						
					
				
				
					commit
					2d01fa4344
				
			
							
								
								
									
										3
									
								
								changelog/24280.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								changelog/24280.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | |||||||
|  | ```release-note:improvement | ||||||
|  | command/server: display logs on startup immediately if disable-gated-logs flag is set | ||||||
|  | ``` | ||||||
| @@ -223,6 +223,11 @@ func (c *AgentCommand) Run(args []string) int { | |||||||
| 		InferLevelsWithTimestamp: true, | 		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) | 	infoKeys := make([]string, 0, 10) | ||||||
| 	info := make(map[string]string) | 	info := make(map[string]string) | ||||||
| 	info["log level"] = config.LogLevel | 	info["log level"] = config.LogLevel | ||||||
|   | |||||||
| @@ -148,6 +148,8 @@ const ( | |||||||
| 	flagNameDisableRedirects = "disable-redirects" | 	flagNameDisableRedirects = "disable-redirects" | ||||||
| 	// flagNameCombineLogs is used to specify whether log output should be combined and sent to stdout | 	// flagNameCombineLogs is used to specify whether log output should be combined and sent to stdout | ||||||
| 	flagNameCombineLogs = "combine-logs" | 	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 is used to specify the path to the log file that Vault should use for logging | ||||||
| 	flagNameLogFile = "log-file" | 	flagNameLogFile = "log-file" | ||||||
| 	// flagNameLogRotateBytes is the flag used to specify the number of bytes a log file should be before it is rotated. | 	// flagNameLogRotateBytes is the flag used to specify the number of bytes a log file should be before it is rotated. | ||||||
|   | |||||||
| @@ -15,6 +15,7 @@ import ( | |||||||
| // logFlags are the 'log' related flags that can be shared across commands. | // logFlags are the 'log' related flags that can be shared across commands. | ||||||
| type logFlags struct { | type logFlags struct { | ||||||
| 	flagCombineLogs       bool | 	flagCombineLogs       bool | ||||||
|  | 	flagDisableGatedLogs  bool | ||||||
| 	flagLogLevel          string | 	flagLogLevel          string | ||||||
| 	flagLogFormat         string | 	flagLogFormat         string | ||||||
| 	flagLogFile           string | 	flagLogFile           string | ||||||
| @@ -41,6 +42,13 @@ func (f *FlagSet) addLogFlags(l *logFlags) { | |||||||
| 		Hidden:  true, | 		Hidden:  true, | ||||||
| 	}) | 	}) | ||||||
|  |  | ||||||
|  | 	f.BoolVar(&BoolVar{ | ||||||
|  | 		Name:    flagDisableGatedLogs, | ||||||
|  | 		Target:  &l.flagDisableGatedLogs, | ||||||
|  | 		Default: false, | ||||||
|  | 		Hidden:  true, | ||||||
|  | 	}) | ||||||
|  |  | ||||||
| 	f.StringVar(&StringVar{ | 	f.StringVar(&StringVar{ | ||||||
| 		Name:       flagNameLogLevel, | 		Name:       flagNameLogLevel, | ||||||
| 		Target:     &l.flagLogLevel, | 		Target:     &l.flagLogLevel, | ||||||
|   | |||||||
| @@ -210,6 +210,11 @@ func (c *ProxyCommand) Run(args []string) int { | |||||||
| 	} | 	} | ||||||
| 	c.logger = l | 	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) | 	infoKeys := make([]string, 0, 10) | ||||||
| 	info := make(map[string]string) | 	info := make(map[string]string) | ||||||
| 	info["log level"] = config.LogLevel | 	info["log level"] = config.LogLevel | ||||||
|   | |||||||
| @@ -1111,6 +1111,11 @@ func (c *ServerCommand) Run(args []string) int { | |||||||
| 	c.logger = l | 	c.logger = l | ||||||
| 	c.allLoggers = append(c.allLoggers, 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 | 	// reporting Errors found in the config | ||||||
| 	for _, cErr := range configErrors { | 	for _, cErr := range configErrors { | ||||||
| 		c.logger.Warn(cErr.String()) | 		c.logger.Warn(cErr.String()) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user