mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-30 18:17:55 +00:00 
			
		
		
		
	api/monitor: Adding log format to monitor command and debug (#15536)
* Correct handling of "unspecified" log level * Setting log-format default on monitor path * Create changelog file * Update website/content/api-docs/system/monitor.mdx Co-authored-by: Chris Capurso <1036769+ccapurso@users.noreply.github.com> Co-authored-by: Chris Capurso <1036769+ccapurso@users.noreply.github.com>
This commit is contained in:
		| @@ -93,6 +93,9 @@ type DebugCommand struct { | ||||
| 	flagOutput          string | ||||
| 	flagTargets         []string | ||||
|  | ||||
| 	// logFormat defines the output format for Monitor | ||||
| 	logFormat string | ||||
|  | ||||
| 	// debugIndex is used to keep track of the index state, which gets written | ||||
| 	// to a file at the end. | ||||
| 	debugIndex *debugIndex | ||||
| @@ -180,6 +183,14 @@ func (c *DebugCommand) Flags() *FlagSets { | ||||
| 			"replication-status, server-status, log.", | ||||
| 	}) | ||||
|  | ||||
| 	f.StringVar(&StringVar{ | ||||
| 		Name:    "log-format", | ||||
| 		Target:  &c.logFormat, | ||||
| 		Default: "standard", | ||||
| 		Usage: "Log format to be captured if \"log\" target specified. " + | ||||
| 			"Supported values are \"standard\" and \"json\". The default is \"standard\".", | ||||
| 	}) | ||||
|  | ||||
| 	return set | ||||
| } | ||||
|  | ||||
| @@ -1053,14 +1064,14 @@ func (c *DebugCommand) captureError(target string, err error) { | ||||
| } | ||||
|  | ||||
| func (c *DebugCommand) writeLogs(ctx context.Context) { | ||||
| 	out, err := os.OpenFile(filepath.Join(c.flagOutput, "vault.log"), os.O_CREATE, 0o600) | ||||
| 	out, err := os.OpenFile(filepath.Join(c.flagOutput, "vault.log"), os.O_CREATE|os.O_WRONLY, 0o600) | ||||
| 	if err != nil { | ||||
| 		c.captureError("log", err) | ||||
| 		return | ||||
| 	} | ||||
| 	defer out.Close() | ||||
|  | ||||
| 	logCh, err := c.cachedClient.Sys().Monitor(ctx, "trace") | ||||
| 	logCh, err := c.cachedClient.Sys().Monitor(ctx, "trace", c.logFormat) | ||||
| 	if err != nil { | ||||
| 		c.captureError("log", err) | ||||
| 		return | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 davidadeleon
					davidadeleon