mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
configurable log level for tests via VAULT_TEST_LOG_LEVEL
This commit is contained in:
1
.github/workflows/test-go.yml
vendored
1
.github/workflows/test-go.yml
vendored
@@ -382,6 +382,7 @@ jobs:
|
||||
VAULT_TEST_LOG_DIR="$(pwd)/test-results/go-test/logs-${{ matrix.id }}"
|
||||
export VAULT_TEST_LOG_DIR
|
||||
mkdir -p "$VAULT_TEST_LOG_DIR"
|
||||
export VAULT_TEST_LOG_LEVEL=info
|
||||
|
||||
|
||||
# shellcheck disable=SC2086 # can't quote RERUN_FAILS
|
||||
|
||||
@@ -19,6 +19,8 @@ import (
|
||||
|
||||
"github.com/hashicorp/eventlogger"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/mitchellh/go-testing-interface"
|
||||
|
||||
"github.com/hashicorp/vault/audit"
|
||||
"github.com/hashicorp/vault/builtin/credential/approle"
|
||||
"github.com/hashicorp/vault/internal/observability/event"
|
||||
@@ -27,7 +29,6 @@ import (
|
||||
"github.com/hashicorp/vault/sdk/helper/consts"
|
||||
"github.com/hashicorp/vault/sdk/helper/salt"
|
||||
"github.com/hashicorp/vault/sdk/logical"
|
||||
"github.com/mitchellh/go-testing-interface"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -561,6 +562,11 @@ func NewTestLogger(t testing.T) *TestLogger {
|
||||
var logPath string
|
||||
output := os.Stderr
|
||||
|
||||
logLevel := hclog.Trace
|
||||
logLevelRaw := os.Getenv("VAULT_TEST_LOG_LEVEL")
|
||||
if logLevelRaw != "" {
|
||||
logLevel = hclog.LevelFromString(logLevelRaw)
|
||||
}
|
||||
logDir := os.Getenv("VAULT_TEST_LOG_DIR")
|
||||
if logDir != "" {
|
||||
logPath = filepath.Join(logDir, t.Name()+".log")
|
||||
@@ -586,7 +592,7 @@ func NewTestLogger(t testing.T) *TestLogger {
|
||||
})
|
||||
sink := hclog.NewSinkAdapter(&hclog.LoggerOptions{
|
||||
Output: output,
|
||||
Level: hclog.Trace,
|
||||
Level: logLevel,
|
||||
IndependentLevels: true,
|
||||
})
|
||||
logger.RegisterSink(sink)
|
||||
|
||||
Reference in New Issue
Block a user