mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 17:52:32 +00:00
Backport of fix -log-file so that it uses the correct name and only adds timestamps on rotation into release/1.14.x (#24322)
* backport of commit 06b9325bb9
* fix server.go imports
---------
Co-authored-by: Peter Wilson <peter.wilson@hashicorp.com>
This commit is contained in:
committed by
GitHub
parent
a75de0e2ab
commit
ec654e3caf
@@ -20,7 +20,7 @@ import (
|
||||
|
||||
systemd "github.com/coreos/go-systemd/daemon"
|
||||
ctconfig "github.com/hashicorp/consul-template/config"
|
||||
hclog "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/hashicorp/go-secure-stdlib/gatedwriter"
|
||||
"github.com/hashicorp/go-secure-stdlib/parseutil"
|
||||
@@ -39,7 +39,7 @@ import (
|
||||
"github.com/hashicorp/vault/command/agent/template"
|
||||
"github.com/hashicorp/vault/command/agentproxyshared"
|
||||
"github.com/hashicorp/vault/command/agentproxyshared/auth"
|
||||
cache "github.com/hashicorp/vault/command/agentproxyshared/cache"
|
||||
"github.com/hashicorp/vault/command/agentproxyshared/cache"
|
||||
"github.com/hashicorp/vault/command/agentproxyshared/sink"
|
||||
"github.com/hashicorp/vault/command/agentproxyshared/sink/file"
|
||||
"github.com/hashicorp/vault/command/agentproxyshared/sink/inmem"
|
||||
@@ -63,6 +63,7 @@ const (
|
||||
// flagNameAgentExitAfterAuth is used as an Agent specific flag to indicate
|
||||
// that agent should exit after a single successful auth
|
||||
flagNameAgentExitAfterAuth = "exit-after-auth"
|
||||
nameAgent = "agent"
|
||||
)
|
||||
|
||||
type AgentCommand struct {
|
||||
@@ -1123,15 +1124,17 @@ func (c *AgentCommand) newLogger() (hclog.InterceptLogger, error) {
|
||||
return nil, errs
|
||||
}
|
||||
|
||||
logCfg := &logging.LogConfig{
|
||||
Name: "agent",
|
||||
LogLevel: logLevel,
|
||||
LogFormat: logFormat,
|
||||
LogFilePath: c.config.LogFile,
|
||||
LogRotateDuration: logRotateDuration,
|
||||
LogRotateBytes: c.config.LogRotateBytes,
|
||||
LogRotateMaxFiles: c.config.LogRotateMaxFiles,
|
||||
logCfg, err := logging.NewLogConfig(nameAgent)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logCfg.Name = nameAgent
|
||||
logCfg.LogLevel = logLevel
|
||||
logCfg.LogFormat = logFormat
|
||||
logCfg.LogFilePath = c.config.LogFile
|
||||
logCfg.LogRotateDuration = logRotateDuration
|
||||
logCfg.LogRotateBytes = c.config.LogRotateBytes
|
||||
logCfg.LogRotateMaxFiles = c.config.LogRotateMaxFiles
|
||||
|
||||
l, err := logging.Setup(logCfg, c.logWriter)
|
||||
if err != nil {
|
||||
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/command/agentproxyshared"
|
||||
"github.com/hashicorp/vault/command/agentproxyshared/auth"
|
||||
cache "github.com/hashicorp/vault/command/agentproxyshared/cache"
|
||||
"github.com/hashicorp/vault/command/agentproxyshared/cache"
|
||||
"github.com/hashicorp/vault/command/agentproxyshared/sink"
|
||||
"github.com/hashicorp/vault/command/agentproxyshared/sink/file"
|
||||
"github.com/hashicorp/vault/command/agentproxyshared/sink/inmem"
|
||||
@@ -59,6 +59,7 @@ const (
|
||||
// flagNameProxyExitAfterAuth is used as a Proxy specific flag to indicate
|
||||
// that proxy should exit after a single successful auth
|
||||
flagNameProxyExitAfterAuth = "exit-after-auth"
|
||||
nameProxy = "proxy"
|
||||
)
|
||||
|
||||
type ProxyCommand struct {
|
||||
@@ -983,15 +984,17 @@ func (c *ProxyCommand) newLogger() (log.InterceptLogger, error) {
|
||||
return nil, errors
|
||||
}
|
||||
|
||||
logCfg := &logging.LogConfig{
|
||||
Name: "proxy",
|
||||
LogLevel: logLevel,
|
||||
LogFormat: logFormat,
|
||||
LogFilePath: c.config.LogFile,
|
||||
LogRotateDuration: logRotateDuration,
|
||||
LogRotateBytes: c.config.LogRotateBytes,
|
||||
LogRotateMaxFiles: c.config.LogRotateMaxFiles,
|
||||
logCfg, err := logging.NewLogConfig(nameProxy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logCfg.Name = nameProxy
|
||||
logCfg.LogLevel = logLevel
|
||||
logCfg.LogFormat = logFormat
|
||||
logCfg.LogFilePath = c.config.LogFile
|
||||
logCfg.LogRotateDuration = logRotateDuration
|
||||
logCfg.LogRotateBytes = c.config.LogRotateBytes
|
||||
logCfg.LogRotateMaxFiles = c.config.LogRotateMaxFiles
|
||||
|
||||
l, err := logging.Setup(logCfg, c.logWriter)
|
||||
if err != nil {
|
||||
|
||||
@@ -1815,14 +1815,16 @@ func (c *ServerCommand) configureLogging(config *server.Config) (hclog.Intercept
|
||||
return nil, err
|
||||
}
|
||||
|
||||
logCfg := &loghelper.LogConfig{
|
||||
LogLevel: logLevel,
|
||||
LogFormat: logFormat,
|
||||
LogFilePath: config.LogFile,
|
||||
LogRotateDuration: logRotateDuration,
|
||||
LogRotateBytes: config.LogRotateBytes,
|
||||
LogRotateMaxFiles: config.LogRotateMaxFiles,
|
||||
logCfg, err := loghelper.NewLogConfig("vault")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logCfg.LogLevel = logLevel
|
||||
logCfg.LogFormat = logFormat
|
||||
logCfg.LogFilePath = config.LogFile
|
||||
logCfg.LogRotateDuration = logRotateDuration
|
||||
logCfg.LogRotateBytes = config.LogRotateBytes
|
||||
logCfg.LogRotateMaxFiles = config.LogRotateMaxFiles
|
||||
|
||||
return loghelper.Setup(logCfg, c.logWriter)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user