Move to "github.com/hashicorp/go-hclog" (#4227)
* logbridge with hclog and identical output * Initial search & replace This compiles, but there is a fair amount of TODO and commented out code, especially around the plugin logclient/logserver code. * strip logbridge * fix majority of tests * update logxi aliases * WIP fixing tests * more test fixes * Update test to hclog * Fix format * Rename hclog -> log * WIP making hclog and logxi love each other * update logger_test.go * clean up merged comments * Replace RawLogger interface with a Logger * Add some logger names * Replace Trace with Debug * update builtin logical logging patterns * Fix build errors * More log updates * update log approach in command and builtin * More log updates * update helper, http, and logical directories * Update loggers * Log updates * Update logging * Update logging * Update logging * Update logging * update logging in physical * prefixing and lowercase * Update logging * Move phyisical logging name to server command * Fix som tests * address jims feedback so far * incorporate brians feedback so far * strip comments * move vault.go to logging package * update Debug to Trace * Update go-plugin deps * Update logging based on review comments * Updates from review * Unvendor logxi * Remove null_logger.go
This commit is contained in:
parent
3f5d60b54b
commit
03cf302e9a
|
@ -18,10 +18,11 @@ import (
|
|||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
auditFile "github.com/hashicorp/vault/builtin/audit/file"
|
||||
credUserpass "github.com/hashicorp/vault/builtin/credential/userpass"
|
||||
vaulthttp "github.com/hashicorp/vault/http"
|
||||
logxi "github.com/mgutz/logxi/v1"
|
||||
dockertest "gopkg.in/ory-am/dockertest.v3"
|
||||
)
|
||||
|
||||
|
@ -42,7 +43,7 @@ func testVaultServerUnseal(t testing.TB) (*api.Client, []string, func()) {
|
|||
return testVaultServerCoreConfig(t, &vault.CoreConfig{
|
||||
DisableMlock: true,
|
||||
DisableCache: true,
|
||||
Logger: logxi.NullLog,
|
||||
Logger: log.NewNullLogger(),
|
||||
CredentialBackends: map[string]logical.Factory{
|
||||
"userpass": credUserpass.Factory,
|
||||
},
|
||||
|
|
|
@ -21,9 +21,8 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
logxi "github.com/mgutz/logxi/v1"
|
||||
|
||||
cleanhttp "github.com/hashicorp/go-cleanhttp"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/api"
|
||||
vaulthttp "github.com/hashicorp/vault/http"
|
||||
|
||||
|
@ -159,7 +158,7 @@ func TestBackend_PermittedDNSDomainsIntermediateCA(t *testing.T) {
|
|||
coreConfig := &vault.CoreConfig{
|
||||
DisableMlock: true,
|
||||
DisableCache: true,
|
||||
Logger: logxi.NullLog,
|
||||
Logger: log.NewNullLogger(),
|
||||
CredentialBackends: map[string]logical.Factory{
|
||||
"cert": Factory,
|
||||
},
|
||||
|
|
|
@ -337,7 +337,7 @@ func (b *backend) loadTrustedCerts(ctx context.Context, storage logical.Storage,
|
|||
trustedNonCAs = make([]*ParsedCert, 0)
|
||||
names, err := storage.List(ctx, "cert/")
|
||||
if err != nil {
|
||||
b.Logger().Error("cert: failed to list trusted certs", "error", err)
|
||||
b.Logger().Error("failed to list trusted certs", "error", err)
|
||||
return
|
||||
}
|
||||
for _, name := range names {
|
||||
|
@ -347,12 +347,12 @@ func (b *backend) loadTrustedCerts(ctx context.Context, storage logical.Storage,
|
|||
}
|
||||
entry, err := b.Cert(ctx, storage, strings.TrimPrefix(name, "cert/"))
|
||||
if err != nil {
|
||||
b.Logger().Error("cert: failed to load trusted cert", "name", name, "error", err)
|
||||
b.Logger().Error("failed to load trusted cert", "name", name, "error", err)
|
||||
continue
|
||||
}
|
||||
parsed := parsePEM([]byte(entry.Certificate))
|
||||
if len(parsed) == 0 {
|
||||
b.Logger().Error("cert: failed to parse certificate", "name", name)
|
||||
b.Logger().Error("failed to parse certificate", "name", name)
|
||||
continue
|
||||
}
|
||||
if !parsed[0].IsCA {
|
||||
|
|
|
@ -121,7 +121,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
|
|||
}
|
||||
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/ldap: User BindDN fetched", "username", username, "binddn", userBindDN)
|
||||
b.Logger().Debug("user binddn fetched", "username", username, "binddn", userBindDN)
|
||||
}
|
||||
|
||||
if cfg.DenyNullBind && len(password) == 0 {
|
||||
|
@ -145,7 +145,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
|
|||
return nil, logical.ErrorResponse(fmt.Sprintf("Encountered an error while attempting to re-bind with the BindDN User: %s", err.Error())), nil, nil
|
||||
}
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/ldap: Re-Bound to original BindDN")
|
||||
b.Logger().Debug("re-bound to original binddn")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
|
|||
return nil, logical.ErrorResponse(err.Error()), nil, nil
|
||||
}
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/ldap: Groups fetched from server", "num_server_groups", len(ldapGroups), "server_groups", ldapGroups)
|
||||
b.Logger().Debug("groups fetched from server", "num_server_groups", len(ldapGroups), "server_groups", ldapGroups)
|
||||
}
|
||||
|
||||
ldapResponse := &logical.Response{
|
||||
|
@ -177,7 +177,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
|
|||
user, err := b.User(ctx, req.Storage, username)
|
||||
if err == nil && user != nil && user.Groups != nil {
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/ldap: adding local groups", "num_local_groups", len(user.Groups), "local_groups", user.Groups)
|
||||
b.Logger().Debug("adding local groups", "num_local_groups", len(user.Groups), "local_groups", user.Groups)
|
||||
}
|
||||
allGroups = append(allGroups, user.Groups...)
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ func (b *backend) getUserBindDN(cfg *ConfigEntry, c *ldap.Conn, username string)
|
|||
|
||||
filter := fmt.Sprintf("(%s=%s)", cfg.UserAttr, ldap.EscapeFilter(username))
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/ldap: Discovering user", "userdn", cfg.UserDN, "filter", filter)
|
||||
b.Logger().Debug("discovering user", "userdn", cfg.UserDN, "filter", filter)
|
||||
}
|
||||
result, err := c.Search(&ldap.SearchRequest{
|
||||
BaseDN: cfg.UserDN,
|
||||
|
@ -295,7 +295,7 @@ func (b *backend) getUserDN(cfg *ConfigEntry, c *ldap.Conn, bindDN string) (stri
|
|||
// Find the distinguished name for the user if userPrincipalName used for login
|
||||
filter := fmt.Sprintf("(userPrincipalName=%s)", ldap.EscapeFilter(bindDN))
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/ldap: Searching UPN", "userdn", cfg.UserDN, "filter", filter)
|
||||
b.Logger().Debug("searching upn", "userdn", cfg.UserDN, "filter", filter)
|
||||
}
|
||||
result, err := c.Search(&ldap.SearchRequest{
|
||||
BaseDN: cfg.UserDN,
|
||||
|
@ -339,19 +339,19 @@ func (b *backend) getLdapGroups(cfg *ConfigEntry, c *ldap.Conn, userDN string, u
|
|||
ldapMap := make(map[string]bool)
|
||||
|
||||
if cfg.GroupFilter == "" {
|
||||
b.Logger().Warn("auth/ldap: GroupFilter is empty, will not query server")
|
||||
b.Logger().Warn("groupfilter is empty, will not query server")
|
||||
return make([]string, 0), nil
|
||||
}
|
||||
|
||||
if cfg.GroupDN == "" {
|
||||
b.Logger().Warn("auth/ldap: GroupDN is empty, will not query server")
|
||||
b.Logger().Warn("groupdn is empty, will not query server")
|
||||
return make([]string, 0), nil
|
||||
}
|
||||
|
||||
// If groupfilter was defined, resolve it as a Go template and use the query for
|
||||
// returning the user's groups
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/ldap: Compiling group filter", "group_filter", cfg.GroupFilter)
|
||||
b.Logger().Debug("compiling group filter", "group_filter", cfg.GroupFilter)
|
||||
}
|
||||
|
||||
// Parse the configuration as a template.
|
||||
|
@ -374,7 +374,7 @@ func (b *backend) getLdapGroups(cfg *ConfigEntry, c *ldap.Conn, userDN string, u
|
|||
t.Execute(&renderedQuery, context)
|
||||
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/ldap: Searching", "groupdn", cfg.GroupDN, "rendered_query", renderedQuery.String())
|
||||
b.Logger().Debug("searching", "groupdn", cfg.GroupDN, "rendered_query", renderedQuery.String())
|
||||
}
|
||||
|
||||
result, err := c.Search(&ldap.SearchRequest{
|
||||
|
|
|
@ -12,11 +12,11 @@ import (
|
|||
"text/template"
|
||||
|
||||
"github.com/go-ldap/ldap"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
"github.com/hashicorp/vault/helper/tlsutil"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/logical/framework"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
func pathConfig(b *backend) *framework.Path {
|
||||
|
@ -427,7 +427,7 @@ func (c *ConfigEntry) DialLDAP() (*ldap.Conn, error) {
|
|||
if err == nil {
|
||||
if retErr != nil {
|
||||
if c.logger.IsDebug() {
|
||||
c.logger.Debug("ldap: errors connecting to some hosts: %s", retErr.Error())
|
||||
c.logger.Debug("errors connecting to some hosts: %s", retErr.Error())
|
||||
}
|
||||
}
|
||||
retErr = nil
|
||||
|
|
|
@ -115,13 +115,13 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
|
|||
switch result.Status {
|
||||
case "LOCKED_OUT":
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/okta: user is locked out", "user", username)
|
||||
b.Logger().Debug("user is locked out", "user", username)
|
||||
}
|
||||
return nil, logical.ErrorResponse("okta authentication failed"), nil, nil
|
||||
|
||||
case "PASSWORD_EXPIRED":
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/okta: password is expired", "user", username)
|
||||
b.Logger().Debug("password is expired", "user", username)
|
||||
}
|
||||
return nil, logical.ErrorResponse("okta authentication failed"), nil, nil
|
||||
|
||||
|
@ -131,7 +131,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
|
|||
case "MFA_ENROLL", "MFA_ENROLL_ACTIVATE":
|
||||
if !cfg.BypassOktaMFA {
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/okta: user must enroll or complete mfa enrollment", "user", username)
|
||||
b.Logger().Debug("user must enroll or complete mfa enrollment", "user", username)
|
||||
}
|
||||
return nil, logical.ErrorResponse("okta authentication failed: you must complete MFA enrollment to continue"), nil, nil
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
|
|||
// Allowed
|
||||
default:
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/okta: unhandled result status", "status", result.Status, "factorstatus", result.FactorResult)
|
||||
b.Logger().Debug("unhandled result status", "status", result.Status, "factorstatus", result.FactorResult)
|
||||
}
|
||||
return nil, logical.ErrorResponse("okta authentication failed"), nil, nil
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
|
|||
|
||||
default:
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/okta: unhandled result status", "status", result.Status)
|
||||
b.Logger().Debug("unhandled result status", "status", result.Status)
|
||||
}
|
||||
return nil, logical.ErrorResponse("okta authentication failed"), nil, nil
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
|
|||
// Allowed
|
||||
default:
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/okta: authentication returned a non-success status", "status", result.Status)
|
||||
b.Logger().Debug("authentication returned a non-success status", "status", result.Status)
|
||||
}
|
||||
return nil, logical.ErrorResponse("okta authentication failed"), nil, nil
|
||||
}
|
||||
|
@ -254,12 +254,12 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
|
|||
user, err := b.User(ctx, req.Storage, username)
|
||||
if err != nil {
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/okta: error looking up user", "error", err)
|
||||
b.Logger().Debug("error looking up user", "error", err)
|
||||
}
|
||||
}
|
||||
if err == nil && user != nil && user.Groups != nil {
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/okta: adding local groups", "num_local_groups", len(user.Groups), "local_groups", user.Groups)
|
||||
b.Logger().Debug("adding local groups", "num_local_groups", len(user.Groups), "local_groups", user.Groups)
|
||||
}
|
||||
allGroups = append(allGroups, user.Groups...)
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ func (b *backend) Login(ctx context.Context, req *logical.Request, username stri
|
|||
entry, _, err := b.Group(ctx, req.Storage, groupName)
|
||||
if err != nil {
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/okta: error looking up group policies", "error", err)
|
||||
b.Logger().Debug("error looking up group policies", "error", err)
|
||||
}
|
||||
}
|
||||
if err == nil && entry != nil && entry.Policies != nil {
|
||||
|
@ -309,7 +309,7 @@ func (b *backend) getOktaGroups(client *okta.Client, user *okta.User) ([]string,
|
|||
oktaGroups = append(oktaGroups, group.Profile.Name)
|
||||
}
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("auth/okta: Groups fetched from Okta", "num_groups", len(oktaGroups), "groups", fmt.Sprintf("%#v", oktaGroups))
|
||||
b.Logger().Debug("Groups fetched from Okta", "num_groups", len(oktaGroups), "groups", fmt.Sprintf("%#v", oktaGroups))
|
||||
}
|
||||
return oktaGroups, nil
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/helper/policyutil"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
|
||||
"time"
|
||||
|
||||
|
@ -21,7 +21,7 @@ func TestBackend_Config(t *testing.T) {
|
|||
defaultLeaseTTLVal := time.Hour * 12
|
||||
maxLeaseTTLVal := time.Hour * 24
|
||||
b, err := Factory(context.Background(), &logical.BackendConfig{
|
||||
Logger: logformat.NewVaultLogger(log.LevelTrace),
|
||||
Logger: logging.NewVaultLogger(log.Trace),
|
||||
System: &logical.StaticSystemView{
|
||||
DefaultLeaseTTLVal: defaultLeaseTTLVal,
|
||||
MaxLeaseTTLVal: maxLeaseTTLVal,
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/hashicorp/errwrap"
|
||||
uuid "github.com/hashicorp/go-uuid"
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"errors"
|
||||
"sync"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/vault/helper/pluginutil"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
// DatabasePluginClient embeds a databasePluginRPCClient and wraps it's Close
|
||||
|
@ -61,7 +61,7 @@ func newPluginClient(ctx context.Context, sys pluginutil.RunnerUtil, pluginRunne
|
|||
case *gRPCClient:
|
||||
db = raw.(*gRPCClient)
|
||||
case *databasePluginRPCClient:
|
||||
logger.Warn("database: plugin is using deprecated net RPC transport, recompile plugin to upgrade to gRPC", "plugin", pluginRunner.Name)
|
||||
logger.Warn("plugin is using deprecated net RPC transport, recompile plugin to upgrade to gRPC", "plugin", pluginRunner.Name)
|
||||
db = raw.(*databasePluginRPCClient)
|
||||
default:
|
||||
return nil, errors.New("unsupported client type")
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/hashicorp/errwrap"
|
||||
|
||||
metrics "github.com/armon/go-metrics"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
)
|
||||
|
||||
// ---- Tracing Middleware Domain ----
|
||||
|
@ -21,9 +21,6 @@ import (
|
|||
type databaseTracingMiddleware struct {
|
||||
next Database
|
||||
logger log.Logger
|
||||
|
||||
typeStr string
|
||||
transport string
|
||||
}
|
||||
|
||||
func (mw *databaseTracingMiddleware) Type() (string, error) {
|
||||
|
@ -32,37 +29,37 @@ func (mw *databaseTracingMiddleware) Type() (string, error) {
|
|||
|
||||
func (mw *databaseTracingMiddleware) CreateUser(ctx context.Context, statements Statements, usernameConfig UsernameConfig, expiration time.Time) (username string, password string, err error) {
|
||||
defer func(then time.Time) {
|
||||
mw.logger.Trace("database", "operation", "CreateUser", "status", "finished", "type", mw.typeStr, "transport", mw.transport, "err", err, "took", time.Since(then))
|
||||
mw.logger.Trace("create user", "status", "finished", "err", err, "took", time.Since(then))
|
||||
}(time.Now())
|
||||
|
||||
mw.logger.Trace("database", "operation", "CreateUser", "status", "started", "type", mw.typeStr, "transport", mw.transport)
|
||||
mw.logger.Trace("create user", "status", "started")
|
||||
return mw.next.CreateUser(ctx, statements, usernameConfig, expiration)
|
||||
}
|
||||
|
||||
func (mw *databaseTracingMiddleware) RenewUser(ctx context.Context, statements Statements, username string, expiration time.Time) (err error) {
|
||||
defer func(then time.Time) {
|
||||
mw.logger.Trace("database", "operation", "RenewUser", "status", "finished", "type", mw.typeStr, "transport", mw.transport, "err", err, "took", time.Since(then))
|
||||
mw.logger.Trace("renew user", "status", "finished", "err", err, "took", time.Since(then))
|
||||
}(time.Now())
|
||||
|
||||
mw.logger.Trace("database", "operation", "RenewUser", "status", "started", mw.typeStr, "transport", mw.transport)
|
||||
mw.logger.Trace("renew user", "status", "started")
|
||||
return mw.next.RenewUser(ctx, statements, username, expiration)
|
||||
}
|
||||
|
||||
func (mw *databaseTracingMiddleware) RevokeUser(ctx context.Context, statements Statements, username string) (err error) {
|
||||
defer func(then time.Time) {
|
||||
mw.logger.Trace("database", "operation", "RevokeUser", "status", "finished", "type", mw.typeStr, "transport", mw.transport, "err", err, "took", time.Since(then))
|
||||
mw.logger.Trace("revoke user", "status", "finished", "err", err, "took", time.Since(then))
|
||||
}(time.Now())
|
||||
|
||||
mw.logger.Trace("database", "operation", "RevokeUser", "status", "started", "type", mw.typeStr, "transport", mw.transport)
|
||||
mw.logger.Trace("revoke user", "status", "started")
|
||||
return mw.next.RevokeUser(ctx, statements, username)
|
||||
}
|
||||
|
||||
func (mw *databaseTracingMiddleware) RotateRootCredentials(ctx context.Context, statements []string) (conf map[string]interface{}, err error) {
|
||||
defer func(then time.Time) {
|
||||
mw.logger.Trace("database", "operation", "RotateRootCredentials", "status", "finished", "type", mw.typeStr, "transport", mw.transport, "err", err, "took", time.Since(then))
|
||||
mw.logger.Trace("rotate root credentials", "status", "finished", "err", err, "took", time.Since(then))
|
||||
}(time.Now())
|
||||
|
||||
mw.logger.Trace("database", "operation", "RotateRootCredentials", "status", "started", "type", mw.typeStr, "transport", mw.transport)
|
||||
mw.logger.Trace("rotate root credentials", "status", "started")
|
||||
return mw.next.RotateRootCredentials(ctx, statements)
|
||||
}
|
||||
|
||||
|
@ -73,19 +70,19 @@ func (mw *databaseTracingMiddleware) Initialize(ctx context.Context, conf map[st
|
|||
|
||||
func (mw *databaseTracingMiddleware) Init(ctx context.Context, conf map[string]interface{}, verifyConnection bool) (saveConf map[string]interface{}, err error) {
|
||||
defer func(then time.Time) {
|
||||
mw.logger.Trace("database", "operation", "Initialize", "status", "finished", "type", mw.typeStr, "transport", mw.transport, "verify", verifyConnection, "err", err, "took", time.Since(then))
|
||||
mw.logger.Trace("initialize", "status", "finished", "verify", verifyConnection, "err", err, "took", time.Since(then))
|
||||
}(time.Now())
|
||||
|
||||
mw.logger.Trace("database", "operation", "Initialize", "status", "started", "type", mw.typeStr, "transport", mw.transport)
|
||||
mw.logger.Trace("initialize", "status", "started")
|
||||
return mw.next.Init(ctx, conf, verifyConnection)
|
||||
}
|
||||
|
||||
func (mw *databaseTracingMiddleware) Close() (err error) {
|
||||
defer func(then time.Time) {
|
||||
mw.logger.Trace("database", "operation", "Close", "status", "finished", "type", mw.typeStr, "transport", mw.transport, "err", err, "took", time.Since(then))
|
||||
mw.logger.Trace("close", "status", "finished", "err", err, "took", time.Since(then))
|
||||
}(time.Now())
|
||||
|
||||
mw.logger.Trace("database", "operation", "Close", "status", "started", "type", mw.typeStr, "transport", mw.transport)
|
||||
mw.logger.Trace("close", "status", "started")
|
||||
return mw.next.Close()
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/hashicorp/errwrap"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/vault/helper/pluginutil"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
// Database is the interface that all database objects must implement.
|
||||
|
@ -39,6 +39,8 @@ func PluginFactory(ctx context.Context, pluginName string, sys pluginutil.LookRu
|
|||
return nil, err
|
||||
}
|
||||
|
||||
namedLogger := logger.Named(pluginName)
|
||||
|
||||
var transport string
|
||||
var db Database
|
||||
if pluginRunner.Builtin {
|
||||
|
@ -59,7 +61,7 @@ func PluginFactory(ctx context.Context, pluginName string, sys pluginutil.LookRu
|
|||
|
||||
} else {
|
||||
// create a DatabasePluginClient instance
|
||||
db, err = newPluginClient(ctx, sys, pluginRunner, logger)
|
||||
db, err = newPluginClient(ctx, sys, pluginRunner, namedLogger)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -87,12 +89,10 @@ func PluginFactory(ctx context.Context, pluginName string, sys pluginutil.LookRu
|
|||
}
|
||||
|
||||
// Wrap with tracing middleware
|
||||
if logger.IsTrace() {
|
||||
if namedLogger.IsTrace() {
|
||||
db = &databaseTracingMiddleware{
|
||||
transport: transport,
|
||||
next: db,
|
||||
typeStr: typeStr,
|
||||
logger: logger,
|
||||
next: db,
|
||||
logger: namedLogger.With("transport", transport),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
plugin "github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/vault/builtin/logical/database/dbplugin"
|
||||
"github.com/hashicorp/vault/helper/pluginutil"
|
||||
|
@ -14,7 +15,6 @@ import (
|
|||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/plugins"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
type mockPlugin struct {
|
||||
|
@ -147,7 +147,7 @@ func TestPlugin_Init(t *testing.T) {
|
|||
cluster, sys := getCluster(t)
|
||||
defer cluster.Cleanup()
|
||||
|
||||
dbRaw, err := dbplugin.PluginFactory(context.Background(), "test-plugin", sys, &log.NullLogger{})
|
||||
dbRaw, err := dbplugin.PluginFactory(context.Background(), "test-plugin", sys, log.NewNullLogger())
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ func TestPlugin_CreateUser(t *testing.T) {
|
|||
cluster, sys := getCluster(t)
|
||||
defer cluster.Cleanup()
|
||||
|
||||
db, err := dbplugin.PluginFactory(context.Background(), "test-plugin", sys, &log.NullLogger{})
|
||||
db, err := dbplugin.PluginFactory(context.Background(), "test-plugin", sys, log.NewNullLogger())
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ func TestPlugin_RenewUser(t *testing.T) {
|
|||
cluster, sys := getCluster(t)
|
||||
defer cluster.Cleanup()
|
||||
|
||||
db, err := dbplugin.PluginFactory(context.Background(), "test-plugin", sys, &log.NullLogger{})
|
||||
db, err := dbplugin.PluginFactory(context.Background(), "test-plugin", sys, log.NewNullLogger())
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ func TestPlugin_RevokeUser(t *testing.T) {
|
|||
cluster, sys := getCluster(t)
|
||||
defer cluster.Cleanup()
|
||||
|
||||
db, err := dbplugin.PluginFactory(context.Background(), "test-plugin", sys, &log.NullLogger{})
|
||||
db, err := dbplugin.PluginFactory(context.Background(), "test-plugin", sys, log.NewNullLogger())
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ func TestPlugin_NetRPC_Init(t *testing.T) {
|
|||
cluster, sys := getCluster(t)
|
||||
defer cluster.Cleanup()
|
||||
|
||||
dbRaw, err := dbplugin.PluginFactory(context.Background(), "test-plugin-netRPC", sys, &log.NullLogger{})
|
||||
dbRaw, err := dbplugin.PluginFactory(context.Background(), "test-plugin-netRPC", sys, log.NewNullLogger())
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ func TestPlugin_NetRPC_CreateUser(t *testing.T) {
|
|||
cluster, sys := getCluster(t)
|
||||
defer cluster.Cleanup()
|
||||
|
||||
db, err := dbplugin.PluginFactory(context.Background(), "test-plugin-netRPC", sys, &log.NullLogger{})
|
||||
db, err := dbplugin.PluginFactory(context.Background(), "test-plugin-netRPC", sys, log.NewNullLogger())
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ func TestPlugin_NetRPC_RenewUser(t *testing.T) {
|
|||
cluster, sys := getCluster(t)
|
||||
defer cluster.Cleanup()
|
||||
|
||||
db, err := dbplugin.PluginFactory(context.Background(), "test-plugin-netRPC", sys, &log.NullLogger{})
|
||||
db, err := dbplugin.PluginFactory(context.Background(), "test-plugin-netRPC", sys, log.NewNullLogger())
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ func TestPlugin_NetRPC_RevokeUser(t *testing.T) {
|
|||
cluster, sys := getCluster(t)
|
||||
defer cluster.Cleanup()
|
||||
|
||||
db, err := dbplugin.PluginFactory(context.Background(), "test-plugin-netRPC", sys, &log.NullLogger{})
|
||||
db, err := dbplugin.PluginFactory(context.Background(), "test-plugin-netRPC", sys, log.NewNullLogger())
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/logical/framework"
|
||||
|
@ -64,8 +64,8 @@ type backend struct {
|
|||
|
||||
// DB returns the database connection.
|
||||
func (b *backend) DB(ctx context.Context, s logical.Storage) (*sql.DB, error) {
|
||||
b.logger.Trace("postgres/db: enter")
|
||||
defer b.logger.Trace("postgres/db: exit")
|
||||
b.logger.Debug("postgres/db: enter")
|
||||
defer b.logger.Debug("postgres/db: exit")
|
||||
|
||||
b.lock.Lock()
|
||||
defer b.lock.Unlock()
|
||||
|
@ -126,8 +126,8 @@ func (b *backend) DB(ctx context.Context, s logical.Storage) (*sql.DB, error) {
|
|||
|
||||
// ResetDB forces a connection next time DB() is called.
|
||||
func (b *backend) ResetDB(_ context.Context) {
|
||||
b.logger.Trace("postgres/resetdb: enter")
|
||||
defer b.logger.Trace("postgres/resetdb: exit")
|
||||
b.logger.Debug("postgres/db: enter")
|
||||
defer b.logger.Debug("postgres/db: exit")
|
||||
|
||||
b.lock.Lock()
|
||||
defer b.lock.Unlock()
|
||||
|
|
|
@ -33,13 +33,9 @@ func pathRoleCreate(b *backend) *framework.Path {
|
|||
}
|
||||
|
||||
func (b *backend) pathRoleCreateRead(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||
b.logger.Trace("postgres/pathRoleCreateRead: enter")
|
||||
defer b.logger.Trace("postgres/pathRoleCreateRead: exit")
|
||||
|
||||
name := data.Get("name").(string)
|
||||
|
||||
// Get the role
|
||||
b.logger.Trace("postgres/pathRoleCreateRead: getting role")
|
||||
role, err := b.Role(ctx, req.Storage, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -49,7 +45,6 @@ func (b *backend) pathRoleCreateRead(ctx context.Context, req *logical.Request,
|
|||
}
|
||||
|
||||
// Determine if we have a lease
|
||||
b.logger.Trace("postgres/pathRoleCreateRead: getting lease")
|
||||
lease, err := b.Lease(ctx, req.Storage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -90,20 +85,17 @@ func (b *backend) pathRoleCreateRead(ctx context.Context, req *logical.Request,
|
|||
Format("2006-01-02 15:04:05-0700")
|
||||
|
||||
// Get our handle
|
||||
b.logger.Trace("postgres/pathRoleCreateRead: getting database handle")
|
||||
db, err := b.DB(ctx, req.Storage)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Start a transaction
|
||||
b.logger.Trace("postgres/pathRoleCreateRead: starting transaction")
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
b.logger.Trace("postgres/pathRoleCreateRead: rolling back transaction")
|
||||
tx.Rollback()
|
||||
}()
|
||||
|
||||
|
@ -114,7 +106,6 @@ func (b *backend) pathRoleCreateRead(ctx context.Context, req *logical.Request,
|
|||
continue
|
||||
}
|
||||
|
||||
b.logger.Trace("postgres/pathRoleCreateRead: preparing statement")
|
||||
stmt, err := tx.Prepare(Query(query, map[string]string{
|
||||
"name": username,
|
||||
"password": password,
|
||||
|
@ -124,7 +115,6 @@ func (b *backend) pathRoleCreateRead(ctx context.Context, req *logical.Request,
|
|||
return nil, err
|
||||
}
|
||||
defer stmt.Close()
|
||||
b.logger.Trace("postgres/pathRoleCreateRead: executing statement")
|
||||
if _, err := stmt.Exec(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -132,14 +122,12 @@ func (b *backend) pathRoleCreateRead(ctx context.Context, req *logical.Request,
|
|||
|
||||
// Commit the transaction
|
||||
|
||||
b.logger.Trace("postgres/pathRoleCreateRead: committing transaction")
|
||||
if err := tx.Commit(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Return the secret
|
||||
|
||||
b.logger.Trace("postgres/pathRoleCreateRead: generating secret")
|
||||
resp := b.Secret(SecretCredsType).Response(map[string]interface{}{
|
||||
"username": username,
|
||||
"password": password,
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"golang.org/x/crypto/ssh"
|
||||
"golang.org/x/crypto/ssh/agent"
|
||||
|
|
|
@ -571,14 +571,14 @@ func (b *backend) pathRoleList(ctx context.Context, req *logical.Request, d *fra
|
|||
if err != nil {
|
||||
// On error, log warning and continue
|
||||
if b.Logger().IsWarn() {
|
||||
b.Logger().Warn("ssh: error getting role info", "role", entry, "error", err)
|
||||
b.Logger().Warn("error getting role info", "role", entry, "error", err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if role == nil {
|
||||
// On empty role, log warning and continue
|
||||
if b.Logger().IsWarn() {
|
||||
b.Logger().Warn("ssh: no role info found", "role", entry)
|
||||
b.Logger().Warn("no role info found", "role", entry)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
@ -586,7 +586,7 @@ func (b *backend) pathRoleList(ctx context.Context, req *logical.Request, d *fra
|
|||
roleInfo, err := b.parseRole(role)
|
||||
if err != nil {
|
||||
if b.Logger().IsWarn() {
|
||||
b.Logger().Warn("ssh: error parsing role info", "role", entry, "error", err)
|
||||
b.Logger().Warn("error parsing role info", "role", entry, "error", err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
"github.com/hashicorp/vault/logical"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
|
|
|
@ -64,8 +64,8 @@ type backend struct {
|
|||
}
|
||||
|
||||
func (b *backend) invalidate(_ context.Context, key string) {
|
||||
if b.Logger().IsTrace() {
|
||||
b.Logger().Trace("transit: invalidating key", "key", key)
|
||||
if b.Logger().IsDebug() {
|
||||
b.Logger().Debug("invalidating key", "key", key)
|
||||
}
|
||||
switch {
|
||||
case strings.HasPrefix(key, "policy/"):
|
||||
|
|
|
@ -86,7 +86,7 @@ type backend struct {
|
|||
}
|
||||
|
||||
func (b *backend) reloadBackend(ctx context.Context) error {
|
||||
b.Logger().Trace("plugin: reloading plugin backend", "plugin", b.config.Config["plugin_name"])
|
||||
b.Logger().Debug("reloading plugin backend", "plugin", b.config.Config["plugin_name"])
|
||||
return b.startBackend(ctx)
|
||||
}
|
||||
|
||||
|
@ -111,12 +111,12 @@ func (b *backend) startBackend(ctx context.Context) error {
|
|||
if !b.loaded {
|
||||
if b.Backend.Type() != nb.Type() {
|
||||
nb.Cleanup(ctx)
|
||||
b.Logger().Warn("plugin: failed to start plugin process", "plugin", b.config.Config["plugin_name"], "error", ErrMismatchType)
|
||||
b.Logger().Warn("failed to start plugin process", "plugin", b.config.Config["plugin_name"], "error", ErrMismatchType)
|
||||
return ErrMismatchType
|
||||
}
|
||||
if !reflect.DeepEqual(b.Backend.SpecialPaths(), nb.SpecialPaths()) {
|
||||
nb.Cleanup(ctx)
|
||||
b.Logger().Warn("plugin: failed to start plugin process", "plugin", b.config.Config["plugin_name"], "error", ErrMismatchPaths)
|
||||
b.Logger().Warn("failed to start plugin process", "plugin", b.config.Config["plugin_name"], "error", ErrMismatchPaths)
|
||||
return ErrMismatchPaths
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/helper/pluginutil"
|
||||
vaulthttp "github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/logical/plugin"
|
||||
"github.com/hashicorp/vault/logical/plugin/mock"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
func TestBackend_impl(t *testing.T) {
|
||||
|
@ -80,7 +80,7 @@ func testConfig(t *testing.T) (*logical.BackendConfig, func()) {
|
|||
sys := vault.TestDynamicSystemView(core.Core)
|
||||
|
||||
config := &logical.BackendConfig{
|
||||
Logger: logformat.NewVaultLogger(log.LevelTrace),
|
||||
Logger: logging.NewVaultLogger(log.Debug),
|
||||
System: sys,
|
||||
Config: map[string]string{
|
||||
"plugin_name": "mock-plugin",
|
||||
|
|
|
@ -4,12 +4,12 @@ import (
|
|||
"sync"
|
||||
"testing"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/api"
|
||||
credAppRole "github.com/hashicorp/vault/builtin/credential/approle"
|
||||
vaulthttp "github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
logxi "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
func TestAppRole_Integ_ConcurrentLogins(t *testing.T) {
|
||||
|
@ -17,7 +17,7 @@ func TestAppRole_Integ_ConcurrentLogins(t *testing.T) {
|
|||
coreConfig := &vault.CoreConfig{
|
||||
DisableMlock: true,
|
||||
DisableCache: true,
|
||||
Logger: logxi.NullLog,
|
||||
Logger: log.NewNullLogger(),
|
||||
CredentialBackends: map[string]logical.Factory{
|
||||
"approle": credAppRole.Factory,
|
||||
},
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/audit"
|
||||
"github.com/hashicorp/vault/builtin/logical/pki"
|
||||
|
@ -22,11 +23,10 @@ import (
|
|||
auditFile "github.com/hashicorp/vault/builtin/audit/file"
|
||||
credUserpass "github.com/hashicorp/vault/builtin/credential/userpass"
|
||||
vaulthttp "github.com/hashicorp/vault/http"
|
||||
logxi "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
var (
|
||||
defaultVaultLogger = logxi.NullLog
|
||||
defaultVaultLogger = log.NewNullLogger()
|
||||
|
||||
defaultVaultCredentialBackends = map[string]logical.Factory{
|
||||
"userpass": credUserpass.Factory,
|
||||
|
|
|
@ -3,12 +3,12 @@ package command
|
|||
import (
|
||||
"testing"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/builtin/credential/ldap"
|
||||
vaulthttp "github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
logxi "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
|
||||
|
@ -16,7 +16,7 @@ func TestIdentityStore_Integ_GroupAliases(t *testing.T) {
|
|||
coreConfig := &vault.CoreConfig{
|
||||
DisableMlock: true,
|
||||
DisableCache: true,
|
||||
Logger: logxi.NullLog,
|
||||
Logger: log.NewNullLogger(),
|
||||
CredentialBackends: map[string]logical.Factory{
|
||||
"ldap": ldap.Factory,
|
||||
},
|
||||
|
|
|
@ -3,11 +3,11 @@ package command
|
|||
import (
|
||||
"testing"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/api"
|
||||
vaulthttp "github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
logxi "github.com/mgutz/logxi/v1"
|
||||
|
||||
credAppId "github.com/hashicorp/vault/builtin/credential/app-id"
|
||||
)
|
||||
|
@ -17,7 +17,7 @@ func TestPathMap_Upgrade_API(t *testing.T) {
|
|||
coreConfig := &vault.CoreConfig{
|
||||
DisableMlock: true,
|
||||
DisableCache: true,
|
||||
Logger: logxi.NullLog,
|
||||
Logger: log.NewNullLogger(),
|
||||
CredentialBackends: map[string]logical.Factory{
|
||||
"app-id": credAppId.Factory,
|
||||
},
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"time"
|
||||
|
||||
colorable "github.com/mattn/go-colorable"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
"github.com/mitchellh/cli"
|
||||
testing "github.com/mitchellh/go-testing-interface"
|
||||
"github.com/posener/complete"
|
||||
|
@ -32,13 +31,12 @@ import (
|
|||
"github.com/armon/go-metrics/circonus"
|
||||
"github.com/armon/go-metrics/datadog"
|
||||
"github.com/hashicorp/errwrap"
|
||||
hclog "github.com/hashicorp/go-hclog"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/hashicorp/vault/audit"
|
||||
"github.com/hashicorp/vault/command/server"
|
||||
"github.com/hashicorp/vault/helper/gated-writer"
|
||||
"github.com/hashicorp/vault/helper/logbridge"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/helper/mlock"
|
||||
"github.com/hashicorp/vault/helper/parseutil"
|
||||
"github.com/hashicorp/vault/helper/reload"
|
||||
|
@ -288,21 +286,19 @@ func (c *ServerCommand) Run(args []string) int {
|
|||
// Create a logger. We wrap it in a gated writer so that it doesn't
|
||||
// start logging too early.
|
||||
c.logGate = &gatedwriter.Writer{Writer: colorable.NewColorable(os.Stderr)}
|
||||
var level int
|
||||
var level log.Level
|
||||
c.flagLogLevel = strings.ToLower(strings.TrimSpace(c.flagLogLevel))
|
||||
switch c.flagLogLevel {
|
||||
case "trace":
|
||||
level = log.LevelTrace
|
||||
level = log.Trace
|
||||
case "debug":
|
||||
level = log.LevelDebug
|
||||
case "info", "":
|
||||
level = log.LevelInfo
|
||||
case "notice":
|
||||
level = log.LevelNotice
|
||||
level = log.Debug
|
||||
case "notice", "info", "":
|
||||
level = log.Info
|
||||
case "warn", "warning":
|
||||
level = log.LevelWarn
|
||||
level = log.Warn
|
||||
case "err", "error":
|
||||
level = log.LevelError
|
||||
level = log.Error
|
||||
default:
|
||||
c.UI.Error(fmt.Sprintf("Unknown log level: %s", c.flagLogLevel))
|
||||
return 1
|
||||
|
@ -315,20 +311,20 @@ func (c *ServerCommand) Run(args []string) int {
|
|||
switch strings.ToLower(logFormat) {
|
||||
case "vault", "vault_json", "vault-json", "vaultjson", "json", "":
|
||||
if c.flagDevThreeNode || c.flagDevFourCluster {
|
||||
c.logger = logbridge.NewLogger(hclog.New(&hclog.LoggerOptions{
|
||||
c.logger = log.New(&log.LoggerOptions{
|
||||
Mutex: &sync.Mutex{},
|
||||
Output: c.logGate,
|
||||
Level: hclog.Trace,
|
||||
})).LogxiLogger()
|
||||
Level: log.Trace,
|
||||
})
|
||||
} else {
|
||||
c.logger = logformat.NewVaultLoggerWithWriter(c.logGate, level)
|
||||
c.logger = logging.NewVaultLoggerWithWriter(c.logGate, level)
|
||||
}
|
||||
default:
|
||||
c.logger = log.NewLogger(c.logGate, "vault")
|
||||
c.logger.SetLevel(level)
|
||||
c.logger = logging.NewVaultLoggerWithWriter(c.logGate, level)
|
||||
}
|
||||
|
||||
grpclog.SetLogger(&grpclogFaker{
|
||||
logger: c.logger,
|
||||
logger: c.logger.Named("grpclogfaker"),
|
||||
log: os.Getenv("VAULT_GRPC_LOGGING") != "",
|
||||
})
|
||||
|
||||
|
@ -412,7 +408,7 @@ func (c *ServerCommand) Run(args []string) int {
|
|||
c.UI.Error(fmt.Sprintf("Unknown storage type %s", config.Storage.Type))
|
||||
return 1
|
||||
}
|
||||
backend, err := factory(config.Storage.Config, c.logger)
|
||||
backend, err := factory(config.Storage.Config, c.logger.ResetNamed("storage."+config.Storage.Type))
|
||||
if err != nil {
|
||||
c.UI.Error(fmt.Sprintf("Error initializing storage of type %s: %s", config.Storage.Type, err))
|
||||
return 1
|
||||
|
@ -718,8 +714,8 @@ CLUSTER_SYNTHESIS_COMPLETE:
|
|||
}
|
||||
c.reloadFuncsLock.Unlock()
|
||||
if !disableClustering {
|
||||
if c.logger.IsTrace() {
|
||||
c.logger.Trace("cluster listener addresses synthesized", "cluster_addresses", clusterAddrs)
|
||||
if c.logger.IsDebug() {
|
||||
c.logger.Debug("cluster listener addresses synthesized", "cluster_addresses", clusterAddrs)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1095,7 +1091,7 @@ func (c *ServerCommand) enableThreeNodeDevCluster(base *vault.CoreConfig, info m
|
|||
testCluster := vault.NewTestCluster(&testing.RuntimeT{}, base, &vault.TestClusterOptions{
|
||||
HandlerFunc: vaulthttp.Handler,
|
||||
BaseListenAddress: c.flagDevListenAddr,
|
||||
RawLogger: c.logger,
|
||||
Logger: c.logger,
|
||||
TempDir: tempDir,
|
||||
})
|
||||
defer c.cleanupGuard.Do(testCluster.Cleanup)
|
||||
|
@ -1577,19 +1573,19 @@ func (g *grpclogFaker) Fatalln(args ...interface{}) {
|
|||
}
|
||||
|
||||
func (g *grpclogFaker) Print(args ...interface{}) {
|
||||
if g.log && g.logger.IsTrace() {
|
||||
g.logger.Trace(fmt.Sprint(args...))
|
||||
if g.log && g.logger.IsDebug() {
|
||||
g.logger.Debug(fmt.Sprint(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (g *grpclogFaker) Printf(format string, args ...interface{}) {
|
||||
if g.log && g.logger.IsTrace() {
|
||||
g.logger.Trace(fmt.Sprintf(format, args...))
|
||||
if g.log && g.logger.IsDebug() {
|
||||
g.logger.Debug(fmt.Sprintf(format, args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (g *grpclogFaker) Println(args ...interface{}) {
|
||||
if g.log && g.logger.IsTrace() {
|
||||
g.logger.Trace(fmt.Sprintln(args...))
|
||||
if g.log && g.logger.IsDebug() {
|
||||
g.logger.Debug(fmt.Sprintln(args...))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/hashicorp/hcl"
|
||||
|
|
|
@ -6,14 +6,14 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/hcl"
|
||||
"github.com/hashicorp/hcl/hcl/ast"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
)
|
||||
|
||||
func TestLoadConfigFile(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
config, err := LoadConfigFile("./test-fixtures/config.hcl", logger)
|
||||
if err != nil {
|
||||
|
@ -79,7 +79,7 @@ func TestLoadConfigFile(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestLoadConfigFile_topLevel(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
config, err := LoadConfigFile("./test-fixtures/config2.hcl", logger)
|
||||
if err != nil {
|
||||
|
@ -150,7 +150,7 @@ func TestLoadConfigFile_topLevel(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestLoadConfigFile_json(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
config, err := LoadConfigFile("./test-fixtures/config.hcl.json", logger)
|
||||
if err != nil {
|
||||
|
@ -215,7 +215,7 @@ func TestLoadConfigFile_json(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestLoadConfigFile_json2(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
config, err := LoadConfigFile("./test-fixtures/config2.hcl.json", logger)
|
||||
if err != nil {
|
||||
|
@ -283,7 +283,7 @@ func TestLoadConfigFile_json2(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestLoadConfigDir(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
config, err := LoadConfigDir("./test-fixtures/config-dir", logger)
|
||||
if err != nil {
|
||||
|
@ -383,7 +383,7 @@ listener "tcp" {
|
|||
}
|
||||
|
||||
func TestParseConfig_badTopLevel(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
_, err := ParseConfig(strings.TrimSpace(`
|
||||
backend {}
|
||||
|
@ -405,7 +405,7 @@ nope = "yes"
|
|||
}
|
||||
|
||||
func TestParseConfig_badListener(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
_, err := ParseConfig(strings.TrimSpace(`
|
||||
listener "tcp" {
|
||||
|
@ -429,7 +429,7 @@ listener "tcp" {
|
|||
}
|
||||
|
||||
func TestParseConfig_badTelemetry(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
_, err := ParseConfig(strings.TrimSpace(`
|
||||
telemetry {
|
||||
|
|
|
@ -1,122 +0,0 @@
|
|||
package logbridge
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
hclog "github.com/hashicorp/go-hclog"
|
||||
)
|
||||
|
||||
type Logger struct {
|
||||
hclogger hclog.Logger
|
||||
}
|
||||
|
||||
func NewLogger(hclogger hclog.Logger) *Logger {
|
||||
return &Logger{hclogger: hclogger}
|
||||
}
|
||||
func (l *Logger) Trace(msg string, args ...interface{}) {
|
||||
l.hclogger.Trace(msg, args...)
|
||||
}
|
||||
func (l *Logger) Debug(msg string, args ...interface{}) {
|
||||
l.hclogger.Debug(msg, args...)
|
||||
}
|
||||
func (l *Logger) Info(msg string, args ...interface{}) {
|
||||
l.hclogger.Info(msg, args...)
|
||||
}
|
||||
func (l *Logger) Warn(msg string, args ...interface{}) {
|
||||
l.hclogger.Warn(msg, args...)
|
||||
}
|
||||
func (l *Logger) Error(msg string, args ...interface{}) {
|
||||
l.hclogger.Error(msg, args...)
|
||||
}
|
||||
func (l *Logger) IsTrace() bool {
|
||||
return l.hclogger.IsTrace()
|
||||
}
|
||||
func (l *Logger) IsDebug() bool {
|
||||
return l.hclogger.IsDebug()
|
||||
}
|
||||
func (l *Logger) IsInfo() bool {
|
||||
return l.hclogger.IsInfo()
|
||||
}
|
||||
func (l *Logger) IsWarn() bool {
|
||||
return l.hclogger.IsWarn()
|
||||
}
|
||||
func (l *Logger) With(args ...interface{}) *Logger {
|
||||
return &Logger{
|
||||
hclogger: l.hclogger.With(args...),
|
||||
}
|
||||
}
|
||||
func (l *Logger) Named(name string) *Logger {
|
||||
return &Logger{
|
||||
hclogger: l.hclogger.Named(name),
|
||||
}
|
||||
}
|
||||
func (l *Logger) ResetNamed(name string) *Logger {
|
||||
return &Logger{
|
||||
hclogger: l.hclogger.ResetNamed(name),
|
||||
}
|
||||
}
|
||||
func (l *Logger) StandardLogger(opts *hclog.StandardLoggerOptions) *log.Logger {
|
||||
return l.hclogger.StandardLogger(opts)
|
||||
}
|
||||
func (l *Logger) LogxiLogger() *LogxiLogger {
|
||||
return &LogxiLogger{
|
||||
l: l,
|
||||
}
|
||||
}
|
||||
|
||||
// This is only for compatibility with whatever the fuck is up with the errors
|
||||
// coming back from warn/error in Logxi's API. Don't use this directly.
|
||||
type LogxiLogger struct {
|
||||
l *Logger
|
||||
}
|
||||
|
||||
func (l *LogxiLogger) Trace(msg string, args ...interface{}) {
|
||||
l.l.Trace(msg, args...)
|
||||
}
|
||||
func (l *LogxiLogger) Debug(msg string, args ...interface{}) {
|
||||
l.l.Debug(msg, args...)
|
||||
}
|
||||
func (l *LogxiLogger) Info(msg string, args ...interface{}) {
|
||||
l.l.Info(msg, args...)
|
||||
}
|
||||
func (l *LogxiLogger) Warn(msg string, args ...interface{}) error {
|
||||
l.l.Warn(msg, args...)
|
||||
return nil
|
||||
}
|
||||
func (l *LogxiLogger) Error(msg string, args ...interface{}) error {
|
||||
l.l.Error(msg, args...)
|
||||
return nil
|
||||
}
|
||||
func (l *LogxiLogger) Fatal(msg string, args ...interface{}) {
|
||||
panic(msg)
|
||||
}
|
||||
func (l *LogxiLogger) Log(level int, msg string, args []interface{}) {
|
||||
panic(msg)
|
||||
}
|
||||
func (l *LogxiLogger) IsTrace() bool {
|
||||
return l.l.IsTrace()
|
||||
}
|
||||
func (l *LogxiLogger) IsDebug() bool {
|
||||
return l.l.IsDebug()
|
||||
}
|
||||
func (l *LogxiLogger) IsInfo() bool {
|
||||
return l.l.IsInfo()
|
||||
}
|
||||
func (l *LogxiLogger) IsWarn() bool {
|
||||
return l.l.IsWarn()
|
||||
}
|
||||
func (l *LogxiLogger) SetLevel(level int) {
|
||||
panic("set level")
|
||||
}
|
||||
func (l *LogxiLogger) With(args ...interface{}) *LogxiLogger {
|
||||
return l.l.With(args...).LogxiLogger()
|
||||
}
|
||||
func (l *LogxiLogger) Named(name string) *LogxiLogger {
|
||||
return l.l.Named(name).LogxiLogger()
|
||||
}
|
||||
func (l *LogxiLogger) ResetNamed(name string) *LogxiLogger {
|
||||
return l.l.ResetNamed(name).LogxiLogger()
|
||||
}
|
||||
func (l *LogxiLogger) StandardLogger(opts *hclog.StandardLoggerOptions) *log.Logger {
|
||||
return l.l.StandardLogger(opts)
|
||||
}
|
|
@ -1,175 +0,0 @@
|
|||
package logformat
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
styledefault = iota
|
||||
stylejson
|
||||
)
|
||||
|
||||
// NewVaultLogger creates a new logger with the specified level and a Vault
|
||||
// formatter
|
||||
func NewVaultLogger(level int) log.Logger {
|
||||
logger := log.New("vault")
|
||||
return setLevelFormatter(logger, level, createVaultFormatter())
|
||||
}
|
||||
|
||||
// NewVaultLoggerWithWriter creates a new logger with the specified level and
|
||||
// writer and a Vault formatter
|
||||
func NewVaultLoggerWithWriter(w io.Writer, level int) log.Logger {
|
||||
logger := log.NewLogger(w, "vault")
|
||||
return setLevelFormatter(logger, level, createVaultFormatter())
|
||||
}
|
||||
|
||||
// Sets the level and formatter on the log, which must be a DefaultLogger
|
||||
func setLevelFormatter(logger log.Logger, level int, formatter log.Formatter) log.Logger {
|
||||
logger.(*log.DefaultLogger).SetLevel(level)
|
||||
logger.(*log.DefaultLogger).SetFormatter(formatter)
|
||||
return logger
|
||||
}
|
||||
|
||||
// Creates a formatter, checking env vars for the style
|
||||
func createVaultFormatter() log.Formatter {
|
||||
ret := &vaultFormatter{
|
||||
Mutex: &sync.Mutex{},
|
||||
}
|
||||
logFormat := os.Getenv("VAULT_LOG_FORMAT")
|
||||
if logFormat == "" {
|
||||
logFormat = os.Getenv("LOGXI_FORMAT")
|
||||
}
|
||||
switch strings.ToLower(logFormat) {
|
||||
case "json", "vault_json", "vault-json", "vaultjson":
|
||||
ret.style = stylejson
|
||||
default:
|
||||
ret.style = styledefault
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// Thread safe formatter
|
||||
type vaultFormatter struct {
|
||||
*sync.Mutex
|
||||
style int
|
||||
module string
|
||||
}
|
||||
|
||||
func (v *vaultFormatter) Format(writer io.Writer, level int, msg string, args []interface{}) {
|
||||
currTime := time.Now()
|
||||
v.Lock()
|
||||
defer v.Unlock()
|
||||
switch v.style {
|
||||
case stylejson:
|
||||
v.formatJSON(writer, currTime, level, msg, args)
|
||||
default:
|
||||
v.formatDefault(writer, currTime, level, msg, args)
|
||||
}
|
||||
}
|
||||
|
||||
func (v *vaultFormatter) formatDefault(writer io.Writer, currTime time.Time, level int, msg string, args []interface{}) {
|
||||
// Write a trailing newline
|
||||
defer writer.Write([]byte("\n"))
|
||||
|
||||
writer.Write([]byte(currTime.Local().Format("2006/01/02 15:04:05.000000")))
|
||||
|
||||
switch level {
|
||||
case log.LevelCritical:
|
||||
writer.Write([]byte(" [CRIT ] "))
|
||||
case log.LevelError:
|
||||
writer.Write([]byte(" [ERROR] "))
|
||||
case log.LevelWarn:
|
||||
writer.Write([]byte(" [WARN ] "))
|
||||
case log.LevelInfo:
|
||||
writer.Write([]byte(" [INFO ] "))
|
||||
case log.LevelDebug:
|
||||
writer.Write([]byte(" [DEBUG] "))
|
||||
case log.LevelTrace:
|
||||
writer.Write([]byte(" [TRACE] "))
|
||||
default:
|
||||
writer.Write([]byte(" [ALL ] "))
|
||||
}
|
||||
|
||||
if v.module != "" {
|
||||
writer.Write([]byte(fmt.Sprintf("(%s) ", v.module)))
|
||||
}
|
||||
|
||||
writer.Write([]byte(msg))
|
||||
|
||||
if args != nil && len(args) > 0 {
|
||||
if len(args)%2 != 0 {
|
||||
args = append(args, "[unknown!]")
|
||||
}
|
||||
|
||||
writer.Write([]byte(":"))
|
||||
|
||||
for i := 0; i < len(args); i = i + 2 {
|
||||
var quote string
|
||||
switch args[i+1].(type) {
|
||||
case string:
|
||||
if strings.ContainsRune(args[i+1].(string), ' ') {
|
||||
quote = `"`
|
||||
}
|
||||
}
|
||||
writer.Write([]byte(fmt.Sprintf(" %s=%s%v%s", args[i], quote, args[i+1], quote)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (v *vaultFormatter) formatJSON(writer io.Writer, currTime time.Time, level int, msg string, args []interface{}) {
|
||||
vals := map[string]interface{}{
|
||||
"@message": msg,
|
||||
"@timestamp": currTime.Format("2006-01-02T15:04:05.000000Z07:00"),
|
||||
}
|
||||
|
||||
var levelStr string
|
||||
switch level {
|
||||
case log.LevelCritical:
|
||||
levelStr = "critical"
|
||||
case log.LevelError:
|
||||
levelStr = "error"
|
||||
case log.LevelWarn:
|
||||
levelStr = "warn"
|
||||
case log.LevelInfo:
|
||||
levelStr = "info"
|
||||
case log.LevelDebug:
|
||||
levelStr = "debug"
|
||||
case log.LevelTrace:
|
||||
levelStr = "trace"
|
||||
default:
|
||||
levelStr = "all"
|
||||
}
|
||||
|
||||
vals["@level"] = levelStr
|
||||
|
||||
if v.module != "" {
|
||||
vals["@module"] = v.module
|
||||
}
|
||||
|
||||
if args != nil && len(args) > 0 {
|
||||
|
||||
if len(args)%2 != 0 {
|
||||
args = append(args, "[unknown!]")
|
||||
}
|
||||
|
||||
for i := 0; i < len(args); i = i + 2 {
|
||||
if _, ok := args[i].(string); !ok {
|
||||
// As this is the logging function not much we can do here
|
||||
// without injecting into logs...
|
||||
continue
|
||||
}
|
||||
vals[args[i].(string)] = args[i+1]
|
||||
}
|
||||
}
|
||||
|
||||
enc := json.NewEncoder(writer)
|
||||
enc.Encode(vals)
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package logging
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
)
|
||||
|
||||
// NewVaultLogger creates a new logger with the specified level and a Vault
|
||||
// formatter
|
||||
func NewVaultLogger(level log.Level) log.Logger {
|
||||
return NewVaultLoggerWithWriter(log.DefaultOutput, level)
|
||||
}
|
||||
|
||||
// NewVaultLoggerWithWriter creates a new logger with the specified level and
|
||||
// writer and a Vault formatter
|
||||
func NewVaultLoggerWithWriter(w io.Writer, level log.Level) log.Logger {
|
||||
opts := &log.LoggerOptions{
|
||||
Level: level,
|
||||
Output: w,
|
||||
JSONFormat: useJson(),
|
||||
}
|
||||
return log.New(opts)
|
||||
}
|
||||
|
||||
func useJson() bool {
|
||||
logFormat := os.Getenv("VAULT_LOG_FORMAT")
|
||||
if logFormat == "" {
|
||||
logFormat = os.Getenv("LOGXI_FORMAT")
|
||||
}
|
||||
switch strings.ToLower(logFormat) {
|
||||
case "json", "vault_json", "vault-json", "vaultjson":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
|
@ -1,158 +0,0 @@
|
|||
package pluginutil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
stdlog "log"
|
||||
"strings"
|
||||
|
||||
hclog "github.com/hashicorp/go-hclog"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
// pluginLogFaker is a wrapper on logxi.Logger that
|
||||
// implements hclog.Logger
|
||||
type hclogFaker struct {
|
||||
logger log.Logger
|
||||
|
||||
name string
|
||||
implied []interface{}
|
||||
}
|
||||
|
||||
func (f *hclogFaker) buildLog(msg string, args ...interface{}) (string, []interface{}) {
|
||||
if f.name != "" {
|
||||
msg = fmt.Sprintf("%s: %s", f.name, msg)
|
||||
}
|
||||
args = append(f.implied, args...)
|
||||
|
||||
return msg, args
|
||||
}
|
||||
|
||||
func (f *hclogFaker) Trace(msg string, args ...interface{}) {
|
||||
msg, args = f.buildLog(msg, args...)
|
||||
f.logger.Trace(msg, args...)
|
||||
}
|
||||
|
||||
func (f *hclogFaker) Debug(msg string, args ...interface{}) {
|
||||
msg, args = f.buildLog(msg, args...)
|
||||
f.logger.Debug(msg, args...)
|
||||
}
|
||||
|
||||
func (f *hclogFaker) Info(msg string, args ...interface{}) {
|
||||
msg, args = f.buildLog(msg, args...)
|
||||
f.logger.Info(msg, args...)
|
||||
}
|
||||
|
||||
func (f *hclogFaker) Warn(msg string, args ...interface{}) {
|
||||
msg, args = f.buildLog(msg, args...)
|
||||
f.logger.Warn(msg, args...)
|
||||
}
|
||||
|
||||
func (f *hclogFaker) Error(msg string, args ...interface{}) {
|
||||
msg, args = f.buildLog(msg, args...)
|
||||
f.logger.Error(msg, args...)
|
||||
}
|
||||
|
||||
func (f *hclogFaker) IsTrace() bool {
|
||||
return f.logger.IsTrace()
|
||||
}
|
||||
|
||||
func (f *hclogFaker) IsDebug() bool {
|
||||
return f.logger.IsDebug()
|
||||
}
|
||||
|
||||
func (f *hclogFaker) IsInfo() bool {
|
||||
return f.logger.IsInfo()
|
||||
}
|
||||
|
||||
func (f *hclogFaker) IsWarn() bool {
|
||||
return f.logger.IsWarn()
|
||||
}
|
||||
|
||||
func (f *hclogFaker) IsError() bool {
|
||||
return !f.logger.IsTrace() && !f.logger.IsDebug() && !f.logger.IsInfo() && !f.IsWarn()
|
||||
}
|
||||
|
||||
func (f *hclogFaker) With(args ...interface{}) hclog.Logger {
|
||||
var nf = *f
|
||||
nf.implied = append(nf.implied, args...)
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *hclogFaker) Named(name string) hclog.Logger {
|
||||
var nf = *f
|
||||
if nf.name != "" {
|
||||
nf.name = nf.name + "." + name
|
||||
}
|
||||
return &nf
|
||||
}
|
||||
|
||||
func (f *hclogFaker) ResetNamed(name string) hclog.Logger {
|
||||
var nf = *f
|
||||
nf.name = name
|
||||
return &nf
|
||||
}
|
||||
|
||||
func (f *hclogFaker) StandardLogger(opts *hclog.StandardLoggerOptions) *stdlog.Logger {
|
||||
if opts == nil {
|
||||
opts = &hclog.StandardLoggerOptions{}
|
||||
}
|
||||
|
||||
return stdlog.New(&stdlogAdapter{f, opts.InferLevels}, "", 0)
|
||||
}
|
||||
|
||||
// Provides a io.Writer to shim the data out of *log.Logger
|
||||
// and back into our Logger. This is basically the only way to
|
||||
// build upon *log.Logger.
|
||||
type stdlogAdapter struct {
|
||||
hl hclog.Logger
|
||||
inferLevels bool
|
||||
}
|
||||
|
||||
// Take the data, infer the levels if configured, and send it through
|
||||
// a regular Logger
|
||||
func (s *stdlogAdapter) Write(data []byte) (int, error) {
|
||||
str := string(bytes.TrimRight(data, " \t\n"))
|
||||
|
||||
if s.inferLevels {
|
||||
level, str := s.pickLevel(str)
|
||||
switch level {
|
||||
case hclog.Trace:
|
||||
s.hl.Trace(str)
|
||||
case hclog.Debug:
|
||||
s.hl.Debug(str)
|
||||
case hclog.Info:
|
||||
s.hl.Info(str)
|
||||
case hclog.Warn:
|
||||
s.hl.Warn(str)
|
||||
case hclog.Error:
|
||||
s.hl.Error(str)
|
||||
default:
|
||||
s.hl.Info(str)
|
||||
}
|
||||
} else {
|
||||
s.hl.Info(str)
|
||||
}
|
||||
|
||||
return len(data), nil
|
||||
}
|
||||
|
||||
// Detect, based on conventions, what log level this is
|
||||
func (s *stdlogAdapter) pickLevel(str string) (hclog.Level, string) {
|
||||
switch {
|
||||
case strings.HasPrefix(str, "[DEBUG]"):
|
||||
return hclog.Debug, strings.TrimSpace(str[7:])
|
||||
case strings.HasPrefix(str, "[TRACE]"):
|
||||
return hclog.Trace, strings.TrimSpace(str[7:])
|
||||
case strings.HasPrefix(str, "[INFO]"):
|
||||
return hclog.Info, strings.TrimSpace(str[6:])
|
||||
case strings.HasPrefix(str, "[WARN]"):
|
||||
return hclog.Warn, strings.TrimSpace(str[7:])
|
||||
case strings.HasPrefix(str, "[ERROR]"):
|
||||
return hclog.Error, strings.TrimSpace(str[7:])
|
||||
case strings.HasPrefix(str, "[ERR]"):
|
||||
return hclog.Error, strings.TrimSpace(str[5:])
|
||||
default:
|
||||
return hclog.Info, str
|
||||
}
|
||||
}
|
|
@ -9,11 +9,11 @@ import (
|
|||
"os/exec"
|
||||
"time"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
plugin "github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/helper/wrapping"
|
||||
"github.com/hashicorp/vault/version"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
// Looker defines the plugin Lookup function that looks into the plugin catalog
|
||||
|
@ -73,12 +73,6 @@ func (r *PluginRunner) runCommon(ctx context.Context, wrapper RunnerUtil, plugin
|
|||
}
|
||||
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", PluginVaultVersionEnv, version.GetVersion().Version))
|
||||
|
||||
// Create logger for the plugin client
|
||||
clogger := &hclogFaker{
|
||||
logger: logger,
|
||||
}
|
||||
namedLogger := clogger.ResetNamed("plugin")
|
||||
|
||||
var clientTLSConfig *tls.Config
|
||||
if !isMetadataMode {
|
||||
// Add the metadata mode ENV and set it to false
|
||||
|
@ -106,7 +100,7 @@ func (r *PluginRunner) runCommon(ctx context.Context, wrapper RunnerUtil, plugin
|
|||
// Add the response wrap token to the ENV of the plugin
|
||||
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", PluginUnwrapTokenEnv, wrapToken))
|
||||
} else {
|
||||
namedLogger = clogger.ResetNamed("plugin.metadata")
|
||||
logger = logger.With("metadata", "true")
|
||||
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", PluginMetadataModeEnv, "true"))
|
||||
}
|
||||
|
||||
|
@ -121,7 +115,7 @@ func (r *PluginRunner) runCommon(ctx context.Context, wrapper RunnerUtil, plugin
|
|||
Cmd: cmd,
|
||||
SecureConfig: secureConfig,
|
||||
TLSConfig: clientTLSConfig,
|
||||
Logger: namedLogger,
|
||||
Logger: logger,
|
||||
AllowedProtocols: []plugin.Protocol{
|
||||
plugin.ProtocolNetRPC,
|
||||
plugin.ProtocolGRPC,
|
||||
|
|
|
@ -10,10 +10,10 @@ import (
|
|||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/hashicorp/errwrap"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/compressutil"
|
||||
"github.com/hashicorp/vault/helper/locksutil"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -347,7 +347,7 @@ func NewStoragePacker(view logical.Storage, logger log.Logger, viewPrefix string
|
|||
packer := &StoragePacker{
|
||||
view: view,
|
||||
viewPrefix: viewPrefix,
|
||||
logger: logger,
|
||||
logger: logger.Named("storagepacker"),
|
||||
storageLocks: locksutil.CreateLocks(),
|
||||
}
|
||||
|
||||
|
|
|
@ -5,14 +5,14 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
uuid "github.com/hashicorp/go-uuid"
|
||||
"github.com/hashicorp/vault/helper/identity"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
func BenchmarkStoragePacker(b *testing.B) {
|
||||
storagePacker, err := NewStoragePacker(&logical.InmemStorage{}, log.New("storagepackertest"), "")
|
||||
storagePacker, err := NewStoragePacker(&logical.InmemStorage{}, log.New(&log.LoggerOptions{Name: "storagepackertest"}), "")
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ func BenchmarkStoragePacker(b *testing.B) {
|
|||
}
|
||||
|
||||
func TestStoragePacker(t *testing.T) {
|
||||
storagePacker, err := NewStoragePacker(&logical.InmemStorage{}, log.New("storagepackertest"), "")
|
||||
storagePacker, err := NewStoragePacker(&logical.InmemStorage{}, log.New(&log.LoggerOptions{Name: "storagepackertest"}), "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ func TestStoragePacker(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStoragePacker_SerializeDeserializeComplexItem(t *testing.T) {
|
||||
storagePacker, err := NewStoragePacker(&logical.InmemStorage{}, log.New("storagepackertest"), "")
|
||||
storagePacker, err := NewStoragePacker(&logical.InmemStorage{}, log.New(&log.LoggerOptions{Name: "storagepackertest"}), "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -290,7 +290,7 @@ func testHTTP_Forwarding_Stress_Common(t *testing.T, parallel bool, num uint64)
|
|||
waitCond.L.Unlock()
|
||||
waitCond.Broadcast()
|
||||
|
||||
core.Logger().Trace("Starting goroutine", "id", id)
|
||||
core.Logger().Debug("Starting goroutine", "id", id)
|
||||
|
||||
startTime := time.Now()
|
||||
for {
|
||||
|
|
|
@ -167,7 +167,7 @@ func handleRequestForwarding(core *vault.Core, handler http.Handler) http.Handle
|
|||
|
||||
if r.Header.Get(NoRequestForwardingHeaderName) != "" {
|
||||
// Forwarding explicitly disabled, fall back to previous behavior
|
||||
core.Logger().Trace("http/handleRequestForwarding: forwarding disabled by client request")
|
||||
core.Logger().Debug("handleRequestForwarding: forwarding disabled by client request")
|
||||
handler.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
@ -202,9 +202,9 @@ func handleRequestForwarding(core *vault.Core, handler http.Handler) http.Handle
|
|||
statusCode, header, retBytes, err := core.ForwardRequest(r)
|
||||
if err != nil {
|
||||
if err == vault.ErrCannotForward {
|
||||
core.Logger().Trace("http/handleRequestForwarding: cannot forward (possibly disabled on active node), falling back")
|
||||
core.Logger().Debug("handleRequestForwarding: cannot forward (possibly disabled on active node), falling back")
|
||||
} else {
|
||||
core.Logger().Error("http/handleRequestForwarding: error forwarding request", "error", err)
|
||||
core.Logger().Error("handleRequestForwarding: error forwarding request", "error", err)
|
||||
}
|
||||
|
||||
// Fall back to redirection
|
||||
|
|
|
@ -13,9 +13,9 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
"github.com/hashicorp/vault/physical/inmem"
|
||||
|
@ -85,7 +85,7 @@ func TestLogical_StandbyRedirect(t *testing.T) {
|
|||
defer ln2.Close()
|
||||
|
||||
// Create an HA Vault
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
inmha, err := inmem.NewInmemHA(nil, logger)
|
||||
if err != nil {
|
||||
|
@ -137,9 +137,9 @@ func TestLogical_StandbyRedirect(t *testing.T) {
|
|||
resp := testHttpPutDisableRedirect(t, root, addr2+"/v1/secret/foo", map[string]interface{}{
|
||||
"data": "bar",
|
||||
})
|
||||
logger.Trace("307 test one starting")
|
||||
logger.Debug("307 test one starting")
|
||||
testResponseStatus(t, resp, 307)
|
||||
logger.Trace("307 test one stopping")
|
||||
logger.Debug("307 test one stopping")
|
||||
|
||||
//// READ to standby
|
||||
resp = testHttpGet(t, root, addr2+"/v1/auth/token/lookup-self")
|
||||
|
@ -181,9 +181,9 @@ func TestLogical_StandbyRedirect(t *testing.T) {
|
|||
|
||||
//// DELETE to standby
|
||||
resp = testHttpDeleteDisableRedirect(t, root, addr2+"/v1/secret/foo")
|
||||
logger.Trace("307 test two starting")
|
||||
logger.Debug("307 test two starting")
|
||||
testResponseStatus(t, resp, 307)
|
||||
logger.Trace("307 test two stopping")
|
||||
logger.Debug("307 test two stopping")
|
||||
}
|
||||
|
||||
func TestLogical_CreateToken(t *testing.T) {
|
||||
|
|
|
@ -8,10 +8,9 @@ import (
|
|||
"sync"
|
||||
"testing"
|
||||
|
||||
hclog "github.com/hashicorp/go-hclog"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/api"
|
||||
bplugin "github.com/hashicorp/vault/builtin/plugin"
|
||||
"github.com/hashicorp/vault/helper/logbridge"
|
||||
"github.com/hashicorp/vault/helper/pluginutil"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/logical/plugin"
|
||||
|
@ -20,8 +19,8 @@ import (
|
|||
"github.com/hashicorp/vault/vault"
|
||||
)
|
||||
|
||||
func getPluginClusterAndCore(t testing.TB, logger *logbridge.Logger) (*vault.TestCluster, *vault.TestClusterCore) {
|
||||
inmha, err := inmem.NewInmemHA(nil, logger.LogxiLogger())
|
||||
func getPluginClusterAndCore(t testing.TB, logger log.Logger) (*vault.TestCluster, *vault.TestClusterCore) {
|
||||
inmha, err := inmem.NewInmemHA(nil, logger)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -35,7 +34,7 @@ func getPluginClusterAndCore(t testing.TB, logger *logbridge.Logger) (*vault.Tes
|
|||
|
||||
cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{
|
||||
HandlerFunc: Handler,
|
||||
RawLogger: logger,
|
||||
Logger: logger.Named("testclusteroptions"),
|
||||
})
|
||||
cluster.Start()
|
||||
|
||||
|
@ -91,9 +90,9 @@ func TestPlugin_PluginMain(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPlugin_MockList(t *testing.T) {
|
||||
logger := logbridge.NewLogger(hclog.New(&hclog.LoggerOptions{
|
||||
logger := log.New(&log.LoggerOptions{
|
||||
Mutex: &sync.Mutex{},
|
||||
}))
|
||||
})
|
||||
cluster, core := getPluginClusterAndCore(t, logger)
|
||||
defer cluster.Cleanup()
|
||||
|
||||
|
@ -129,9 +128,9 @@ func TestPlugin_MockList(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPlugin_MockRawResponse(t *testing.T) {
|
||||
logger := logbridge.NewLogger(hclog.New(&hclog.LoggerOptions{
|
||||
logger := log.New(&log.LoggerOptions{
|
||||
Mutex: &sync.Mutex{},
|
||||
}))
|
||||
})
|
||||
cluster, core := getPluginClusterAndCore(t, logger)
|
||||
defer cluster.Cleanup()
|
||||
|
||||
|
@ -155,9 +154,9 @@ func TestPlugin_MockRawResponse(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPlugin_GetParams(t *testing.T) {
|
||||
logger := logbridge.NewLogger(hclog.New(&hclog.LoggerOptions{
|
||||
logger := log.New(&log.LoggerOptions{
|
||||
Mutex: &sync.Mutex{},
|
||||
}))
|
||||
})
|
||||
cluster, core := getPluginClusterAndCore(t, logger)
|
||||
defer cluster.Cleanup()
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/hashicorp/vault/helper/errutil"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/helper/parseutil"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
)
|
||||
|
@ -255,7 +255,7 @@ func (b *Backend) Logger() log.Logger {
|
|||
return b.logger
|
||||
}
|
||||
|
||||
return logformat.NewVaultLoggerWithWriter(ioutil.Discard, log.LevelOff)
|
||||
return logging.NewVaultLoggerWithWriter(ioutil.Discard, log.NoLevel)
|
||||
}
|
||||
|
||||
// System returns the backend's system view.
|
||||
|
|
|
@ -3,7 +3,7 @@ package logical
|
|||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
)
|
||||
|
||||
// BackendType is the type of backend that is being implemented
|
||||
|
|
|
@ -7,9 +7,8 @@ import (
|
|||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
hclog "github.com/hashicorp/go-hclog"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/vault/helper/logbridge"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/logical/plugin/pb"
|
||||
)
|
||||
|
@ -18,12 +17,18 @@ import (
|
|||
type BackendPlugin struct {
|
||||
Factory logical.Factory
|
||||
metadataMode bool
|
||||
Logger hclog.Logger
|
||||
Logger log.Logger
|
||||
}
|
||||
|
||||
// Server gets called when on plugin.Serve()
|
||||
func (b *BackendPlugin) Server(broker *plugin.MuxBroker) (interface{}, error) {
|
||||
return &backendPluginServer{factory: b.Factory, broker: broker}, nil
|
||||
return &backendPluginServer{
|
||||
factory: b.Factory,
|
||||
broker: broker,
|
||||
// We pass the logger down into the backend so go-plugin will forward
|
||||
// logs for us.
|
||||
logger: b.Logger,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Client gets called on plugin.NewClient()
|
||||
|
@ -37,7 +42,7 @@ func (b BackendPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) err
|
|||
factory: b.Factory,
|
||||
// We pass the logger down into the backend so go-plugin will forward
|
||||
// logs for us.
|
||||
logger: logbridge.NewLogger(b.Logger).LogxiLogger(),
|
||||
logger: b.Logger,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"errors"
|
||||
"net/rpc"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -204,16 +204,6 @@ func (b *backendPluginClient) Setup(ctx context.Context, config *logical.Backend
|
|||
impl: storageImpl,
|
||||
})
|
||||
|
||||
// Shim log.Logger
|
||||
loggerImpl := config.Logger
|
||||
if b.metadataMode {
|
||||
loggerImpl = log.NullLog
|
||||
}
|
||||
loggerID := b.broker.NextId()
|
||||
go b.broker.AcceptAndServe(loggerID, &LoggerServer{
|
||||
logger: loggerImpl,
|
||||
})
|
||||
|
||||
// Shim logical.SystemView
|
||||
sysViewImpl := config.System
|
||||
if b.metadataMode {
|
||||
|
@ -226,7 +216,6 @@ func (b *backendPluginClient) Setup(ctx context.Context, config *logical.Backend
|
|||
|
||||
args := &SetupArgs{
|
||||
StorageID: storageID,
|
||||
LoggerID: loggerID,
|
||||
SysViewID: sysViewID,
|
||||
Config: config.Config,
|
||||
BackendUUID: config.BackendUUID,
|
||||
|
|
|
@ -6,6 +6,8 @@ import (
|
|||
"net/rpc"
|
||||
"os"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/vault/helper/pluginutil"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
|
@ -22,7 +24,7 @@ type backendPluginServer struct {
|
|||
backend logical.Backend
|
||||
factory logical.Factory
|
||||
|
||||
loggerClient *rpc.Client
|
||||
logger hclog.Logger
|
||||
sysViewClient *rpc.Client
|
||||
storageClient *rpc.Client
|
||||
}
|
||||
|
@ -77,7 +79,6 @@ func (b *backendPluginServer) Cleanup(_ interface{}, _ *struct{}) error {
|
|||
b.backend.Cleanup(context.Background())
|
||||
|
||||
// Close rpc clients
|
||||
b.loggerClient.Close()
|
||||
b.sysViewClient.Close()
|
||||
b.storageClient.Close()
|
||||
return nil
|
||||
|
@ -109,19 +110,6 @@ func (b *backendPluginServer) Setup(args *SetupArgs, reply *SetupReply) error {
|
|||
|
||||
storage := &StorageClient{client: rawStorageClient}
|
||||
|
||||
// Dial for logger
|
||||
loggerConn, err := b.broker.Dial(args.LoggerID)
|
||||
if err != nil {
|
||||
*reply = SetupReply{
|
||||
Error: wrapError(err),
|
||||
}
|
||||
return nil
|
||||
}
|
||||
rawLoggerClient := rpc.NewClient(loggerConn)
|
||||
b.loggerClient = rawLoggerClient
|
||||
|
||||
logger := &LoggerClient{client: rawLoggerClient}
|
||||
|
||||
// Dial for sys view
|
||||
sysViewConn, err := b.broker.Dial(args.SysViewID)
|
||||
if err != nil {
|
||||
|
@ -137,7 +125,7 @@ func (b *backendPluginServer) Setup(args *SetupArgs, reply *SetupReply) error {
|
|||
|
||||
config := &logical.BackendConfig{
|
||||
StorageView: storage,
|
||||
Logger: logger,
|
||||
Logger: b.logger,
|
||||
System: sysView,
|
||||
Config: args.Config,
|
||||
BackendUUID: args.BackendUUID,
|
||||
|
|
|
@ -5,11 +5,11 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
gplugin "github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/logical/plugin/mock"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
func TestBackendPlugin_impl(t *testing.T) {
|
||||
|
@ -156,7 +156,7 @@ func testBackend(t *testing.T) (logical.Backend, func()) {
|
|||
b := raw.(logical.Backend)
|
||||
|
||||
err = b.Setup(context.Background(), &logical.BackendConfig{
|
||||
Logger: logformat.NewVaultLogger(log.LevelTrace),
|
||||
Logger: logging.NewVaultLogger(log.Debug),
|
||||
System: &logical.StaticSystemView{
|
||||
DefaultLeaseTTLVal: 300 * time.Second,
|
||||
MaxLeaseTTLVal: 1800 * time.Second,
|
||||
|
|
|
@ -7,11 +7,11 @@ import (
|
|||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/vault/helper/pluginutil"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/logical/plugin/pb"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
var ErrPluginShutdown = errors.New("plugin is shut down")
|
||||
|
|
|
@ -3,10 +3,10 @@ package plugin
|
|||
import (
|
||||
"context"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
plugin "github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/logical/plugin/pb"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
|
|
|
@ -6,12 +6,11 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
hclog "github.com/hashicorp/go-hclog"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
gplugin "github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/logical/plugin/mock"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
func TestGRPCBackendPlugin_impl(t *testing.T) {
|
||||
|
@ -143,8 +142,8 @@ func testGRPCBackend(t *testing.T) (logical.Backend, func()) {
|
|||
pluginMap := map[string]gplugin.Plugin{
|
||||
"backend": &BackendPlugin{
|
||||
Factory: mock.Factory,
|
||||
Logger: hclog.New(&hclog.LoggerOptions{
|
||||
Level: hclog.Trace,
|
||||
Logger: log.New(&log.LoggerOptions{
|
||||
Level: log.Debug,
|
||||
Output: os.Stderr,
|
||||
JSONFormat: true,
|
||||
}),
|
||||
|
@ -163,7 +162,7 @@ func testGRPCBackend(t *testing.T) (logical.Backend, func()) {
|
|||
b := raw.(logical.Backend)
|
||||
|
||||
err = b.Setup(context.Background(), &logical.BackendConfig{
|
||||
Logger: logformat.NewVaultLogger(log.LevelTrace),
|
||||
Logger: logging.NewVaultLogger(log.Debug),
|
||||
System: &logical.StaticSystemView{
|
||||
DefaultLeaseTTLVal: 300 * time.Second,
|
||||
MaxLeaseTTLVal: 1800 * time.Second,
|
||||
|
|
|
@ -1,114 +1,9 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"net/rpc"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
type LoggerClient struct {
|
||||
client *rpc.Client
|
||||
}
|
||||
|
||||
func (l *LoggerClient) Trace(msg string, args ...interface{}) {
|
||||
cArgs := &LoggerArgs{
|
||||
Msg: msg,
|
||||
Args: args,
|
||||
}
|
||||
l.client.Call("Plugin.Trace", cArgs, &struct{}{})
|
||||
}
|
||||
|
||||
func (l *LoggerClient) Debug(msg string, args ...interface{}) {
|
||||
cArgs := &LoggerArgs{
|
||||
Msg: msg,
|
||||
Args: args,
|
||||
}
|
||||
l.client.Call("Plugin.Debug", cArgs, &struct{}{})
|
||||
}
|
||||
|
||||
func (l *LoggerClient) Info(msg string, args ...interface{}) {
|
||||
cArgs := &LoggerArgs{
|
||||
Msg: msg,
|
||||
Args: args,
|
||||
}
|
||||
l.client.Call("Plugin.Info", cArgs, &struct{}{})
|
||||
}
|
||||
func (l *LoggerClient) Warn(msg string, args ...interface{}) error {
|
||||
var reply LoggerReply
|
||||
cArgs := &LoggerArgs{
|
||||
Msg: msg,
|
||||
Args: args,
|
||||
}
|
||||
err := l.client.Call("Plugin.Warn", cArgs, &reply)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if reply.Error != nil {
|
||||
return reply.Error
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
func (l *LoggerClient) Error(msg string, args ...interface{}) error {
|
||||
var reply LoggerReply
|
||||
cArgs := &LoggerArgs{
|
||||
Msg: msg,
|
||||
Args: args,
|
||||
}
|
||||
err := l.client.Call("Plugin.Error", cArgs, &reply)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if reply.Error != nil {
|
||||
return reply.Error
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *LoggerClient) Fatal(msg string, args ...interface{}) {
|
||||
// NOOP since it's not actually used within vault
|
||||
return
|
||||
}
|
||||
|
||||
func (l *LoggerClient) Log(level int, msg string, args []interface{}) {
|
||||
cArgs := &LoggerArgs{
|
||||
Level: level,
|
||||
Msg: msg,
|
||||
Args: args,
|
||||
}
|
||||
l.client.Call("Plugin.Log", cArgs, &struct{}{})
|
||||
}
|
||||
|
||||
func (l *LoggerClient) SetLevel(level int) {
|
||||
l.client.Call("Plugin.SetLevel", level, &struct{}{})
|
||||
}
|
||||
|
||||
func (l *LoggerClient) IsTrace() bool {
|
||||
var reply LoggerReply
|
||||
l.client.Call("Plugin.IsTrace", new(interface{}), &reply)
|
||||
return reply.IsTrue
|
||||
}
|
||||
func (l *LoggerClient) IsDebug() bool {
|
||||
var reply LoggerReply
|
||||
l.client.Call("Plugin.IsDebug", new(interface{}), &reply)
|
||||
return reply.IsTrue
|
||||
}
|
||||
|
||||
func (l *LoggerClient) IsInfo() bool {
|
||||
var reply LoggerReply
|
||||
l.client.Call("Plugin.IsInfo", new(interface{}), &reply)
|
||||
return reply.IsTrue
|
||||
}
|
||||
|
||||
func (l *LoggerClient) IsWarn() bool {
|
||||
var reply LoggerReply
|
||||
l.client.Call("Plugin.IsWarn", new(interface{}), &reply)
|
||||
return reply.IsTrue
|
||||
}
|
||||
import hclog "github.com/hashicorp/go-hclog"
|
||||
|
||||
type LoggerServer struct {
|
||||
logger log.Logger
|
||||
logger hclog.Logger
|
||||
}
|
||||
|
||||
func (l *LoggerServer) Trace(args *LoggerArgs, _ *struct{}) error {
|
||||
|
@ -127,34 +22,42 @@ func (l *LoggerServer) Info(args *LoggerArgs, _ *struct{}) error {
|
|||
}
|
||||
|
||||
func (l *LoggerServer) Warn(args *LoggerArgs, reply *LoggerReply) error {
|
||||
err := l.logger.Warn(args.Msg, args.Args...)
|
||||
if err != nil {
|
||||
*reply = LoggerReply{
|
||||
Error: wrapError(err),
|
||||
}
|
||||
return nil
|
||||
}
|
||||
l.logger.Warn(args.Msg, args.Args...)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *LoggerServer) Error(args *LoggerArgs, reply *LoggerReply) error {
|
||||
err := l.logger.Error(args.Msg, args.Args...)
|
||||
if err != nil {
|
||||
*reply = LoggerReply{
|
||||
Error: wrapError(err),
|
||||
}
|
||||
return nil
|
||||
}
|
||||
l.logger.Error(args.Msg, args.Args...)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *LoggerServer) Log(args *LoggerArgs, _ *struct{}) error {
|
||||
l.logger.Log(args.Level, args.Msg, args.Args)
|
||||
|
||||
switch translateLevel(args.Level) {
|
||||
|
||||
case hclog.Trace:
|
||||
l.logger.Trace(args.Msg, args.Args...)
|
||||
|
||||
case hclog.Debug:
|
||||
l.logger.Debug(args.Msg, args.Args...)
|
||||
|
||||
case hclog.Info:
|
||||
l.logger.Info(args.Msg, args.Args...)
|
||||
|
||||
case hclog.Warn:
|
||||
l.logger.Warn(args.Msg, args.Args...)
|
||||
|
||||
case hclog.Error:
|
||||
l.logger.Error(args.Msg, args.Args...)
|
||||
|
||||
case hclog.NoLevel:
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *LoggerServer) SetLevel(args int, _ *struct{}) error {
|
||||
l.logger.SetLevel(args)
|
||||
level := translateLevel(args)
|
||||
l.logger = hclog.New(&hclog.LoggerOptions{Level: level})
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -202,3 +105,30 @@ type LoggerReply struct {
|
|||
IsTrue bool
|
||||
Error error
|
||||
}
|
||||
|
||||
func translateLevel(logxiLevel int) hclog.Level {
|
||||
|
||||
switch logxiLevel {
|
||||
|
||||
case 1000, 10:
|
||||
// logxi.LevelAll, logxi.LevelTrace:
|
||||
return hclog.Trace
|
||||
|
||||
case 7:
|
||||
// logxi.LevelDebug:
|
||||
return hclog.Debug
|
||||
|
||||
case 6, 5:
|
||||
// logxi.LevelInfo, logxi.LevelNotice:
|
||||
return hclog.Info
|
||||
|
||||
case 4:
|
||||
// logxi.LevelWarn:
|
||||
return hclog.Warn
|
||||
|
||||
case 3, 2, 1, -1:
|
||||
// logxi.LevelError, logxi.LevelFatal, logxi.LevelAlert, logxi.LevelEmergency:
|
||||
return hclog.Error
|
||||
}
|
||||
return hclog.NoLevel
|
||||
}
|
||||
|
|
|
@ -4,17 +4,15 @@ import (
|
|||
"bufio"
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"net/rpc"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
plugin "github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
"github.com/hashicorp/go-hclog"
|
||||
|
||||
func TestLogger_impl(t *testing.T) {
|
||||
var _ log.Logger = new(LoggerClient)
|
||||
}
|
||||
plugin "github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
)
|
||||
|
||||
func TestLogger_levels(t *testing.T) {
|
||||
client, server := plugin.TestRPCConn(t)
|
||||
|
@ -23,14 +21,14 @@ func TestLogger_levels(t *testing.T) {
|
|||
var buf bytes.Buffer
|
||||
writer := bufio.NewWriter(&buf)
|
||||
|
||||
l := logformat.NewVaultLoggerWithWriter(writer, log.LevelTrace)
|
||||
l := logging.NewVaultLoggerWithWriter(writer, hclog.Trace)
|
||||
|
||||
server.RegisterName("Plugin", &LoggerServer{
|
||||
logger: l,
|
||||
})
|
||||
|
||||
expected := "foobar"
|
||||
testLogger := &LoggerClient{client: client}
|
||||
testLogger := &deprecatedLoggerClient{client: client}
|
||||
|
||||
// Test trace
|
||||
testLogger.Trace(expected)
|
||||
|
@ -103,13 +101,13 @@ func TestLogger_isLevels(t *testing.T) {
|
|||
client, server := plugin.TestRPCConn(t)
|
||||
defer client.Close()
|
||||
|
||||
l := logformat.NewVaultLoggerWithWriter(ioutil.Discard, log.LevelAll)
|
||||
l := logging.NewVaultLoggerWithWriter(ioutil.Discard, hclog.Trace)
|
||||
|
||||
server.RegisterName("Plugin", &LoggerServer{
|
||||
logger: l,
|
||||
})
|
||||
|
||||
testLogger := &LoggerClient{client: client}
|
||||
testLogger := &deprecatedLoggerClient{client: client}
|
||||
|
||||
if !testLogger.IsDebug() || !testLogger.IsInfo() || !testLogger.IsTrace() || !testLogger.IsWarn() {
|
||||
t.Fatal("expected logger to return true for all logger level checks")
|
||||
|
@ -123,17 +121,17 @@ func TestLogger_log(t *testing.T) {
|
|||
var buf bytes.Buffer
|
||||
writer := bufio.NewWriter(&buf)
|
||||
|
||||
l := logformat.NewVaultLoggerWithWriter(writer, log.LevelTrace)
|
||||
l := logging.NewVaultLoggerWithWriter(writer, hclog.Trace)
|
||||
|
||||
server.RegisterName("Plugin", &LoggerServer{
|
||||
logger: l,
|
||||
})
|
||||
|
||||
expected := "foobar"
|
||||
testLogger := &LoggerClient{client: client}
|
||||
testLogger := &deprecatedLoggerClient{client: client}
|
||||
|
||||
// Test trace
|
||||
testLogger.Log(log.LevelInfo, expected, nil)
|
||||
// Test trace 6 = logxi.LevelInfo
|
||||
testLogger.Log(6, expected, nil)
|
||||
if err := writer.Flush(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -148,16 +146,117 @@ func TestLogger_setLevel(t *testing.T) {
|
|||
client, server := plugin.TestRPCConn(t)
|
||||
defer client.Close()
|
||||
|
||||
l := log.NewLogger(ioutil.Discard, "test-logger")
|
||||
l := hclog.New(&hclog.LoggerOptions{Output: ioutil.Discard})
|
||||
|
||||
server.RegisterName("Plugin", &LoggerServer{
|
||||
logger: l,
|
||||
})
|
||||
|
||||
testLogger := &LoggerClient{client: client}
|
||||
testLogger.SetLevel(log.LevelWarn)
|
||||
testLogger := &deprecatedLoggerClient{client: client}
|
||||
testLogger.SetLevel(4) // 4 == logxi.LevelWarn
|
||||
|
||||
if !testLogger.IsWarn() {
|
||||
t.Fatal("expected logger to support warn level")
|
||||
}
|
||||
}
|
||||
|
||||
type deprecatedLoggerClient struct {
|
||||
client *rpc.Client
|
||||
}
|
||||
|
||||
func (l *deprecatedLoggerClient) Trace(msg string, args ...interface{}) {
|
||||
cArgs := &LoggerArgs{
|
||||
Msg: msg,
|
||||
Args: args,
|
||||
}
|
||||
l.client.Call("Plugin.Trace", cArgs, &struct{}{})
|
||||
}
|
||||
|
||||
func (l *deprecatedLoggerClient) Debug(msg string, args ...interface{}) {
|
||||
cArgs := &LoggerArgs{
|
||||
Msg: msg,
|
||||
Args: args,
|
||||
}
|
||||
l.client.Call("Plugin.Debug", cArgs, &struct{}{})
|
||||
}
|
||||
|
||||
func (l *deprecatedLoggerClient) Info(msg string, args ...interface{}) {
|
||||
cArgs := &LoggerArgs{
|
||||
Msg: msg,
|
||||
Args: args,
|
||||
}
|
||||
l.client.Call("Plugin.Info", cArgs, &struct{}{})
|
||||
}
|
||||
func (l *deprecatedLoggerClient) Warn(msg string, args ...interface{}) error {
|
||||
var reply LoggerReply
|
||||
cArgs := &LoggerArgs{
|
||||
Msg: msg,
|
||||
Args: args,
|
||||
}
|
||||
err := l.client.Call("Plugin.Warn", cArgs, &reply)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if reply.Error != nil {
|
||||
return reply.Error
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
func (l *deprecatedLoggerClient) Error(msg string, args ...interface{}) error {
|
||||
var reply LoggerReply
|
||||
cArgs := &LoggerArgs{
|
||||
Msg: msg,
|
||||
Args: args,
|
||||
}
|
||||
err := l.client.Call("Plugin.Error", cArgs, &reply)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if reply.Error != nil {
|
||||
return reply.Error
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *deprecatedLoggerClient) Fatal(msg string, args ...interface{}) {
|
||||
// NOOP since it's not actually used within vault
|
||||
return
|
||||
}
|
||||
|
||||
func (l *deprecatedLoggerClient) Log(level int, msg string, args []interface{}) {
|
||||
cArgs := &LoggerArgs{
|
||||
Level: level,
|
||||
Msg: msg,
|
||||
Args: args,
|
||||
}
|
||||
l.client.Call("Plugin.Log", cArgs, &struct{}{})
|
||||
}
|
||||
|
||||
func (l *deprecatedLoggerClient) SetLevel(level int) {
|
||||
l.client.Call("Plugin.SetLevel", level, &struct{}{})
|
||||
}
|
||||
|
||||
func (l *deprecatedLoggerClient) IsTrace() bool {
|
||||
var reply LoggerReply
|
||||
l.client.Call("Plugin.IsTrace", new(interface{}), &reply)
|
||||
return reply.IsTrue
|
||||
}
|
||||
func (l *deprecatedLoggerClient) IsDebug() bool {
|
||||
var reply LoggerReply
|
||||
l.client.Call("Plugin.IsDebug", new(interface{}), &reply)
|
||||
return reply.IsTrue
|
||||
}
|
||||
|
||||
func (l *deprecatedLoggerClient) IsInfo() bool {
|
||||
var reply LoggerReply
|
||||
l.client.Call("Plugin.IsInfo", new(interface{}), &reply)
|
||||
return reply.IsTrue
|
||||
}
|
||||
|
||||
func (l *deprecatedLoggerClient) IsWarn() bool {
|
||||
var reply LoggerReply
|
||||
l.client.Call("Plugin.IsWarn", new(interface{}), &reply)
|
||||
return reply.IsTrue
|
||||
}
|
||||
|
|
|
@ -4,16 +4,14 @@ import (
|
|||
"context"
|
||||
"time"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
// backendPluginClient implements logical.Backend and is the
|
||||
// go-plugin client.
|
||||
type backendTracingMiddleware struct {
|
||||
logger log.Logger
|
||||
transport string
|
||||
typeStr string
|
||||
logger log.Logger
|
||||
|
||||
next logical.Backend
|
||||
}
|
||||
|
@ -23,19 +21,19 @@ var _ logical.Backend = &backendTracingMiddleware{}
|
|||
|
||||
func (b *backendTracingMiddleware) HandleRequest(ctx context.Context, req *logical.Request) (resp *logical.Response, err error) {
|
||||
defer func(then time.Time) {
|
||||
b.logger.Trace("plugin.HandleRequest", "path", req.Path, "status", "finished", "type", b.typeStr, "transport", b.transport, "err", err, "took", time.Since(then))
|
||||
b.logger.Trace("handle request", "path", req.Path, "status", "finished", "err", err, "took", time.Since(then))
|
||||
}(time.Now())
|
||||
|
||||
b.logger.Trace("plugin.HandleRequest", "path", req.Path, "status", "started", "type", b.typeStr, "transport", b.transport)
|
||||
b.logger.Trace("handle request", "path", req.Path, "status", "started")
|
||||
return b.next.HandleRequest(ctx, req)
|
||||
}
|
||||
|
||||
func (b *backendTracingMiddleware) SpecialPaths() *logical.Paths {
|
||||
defer func(then time.Time) {
|
||||
b.logger.Trace("plugin.SpecialPaths", "status", "finished", "type", b.typeStr, "transport", b.transport, "took", time.Since(then))
|
||||
b.logger.Trace("special paths", "status", "finished", "took", time.Since(then))
|
||||
}(time.Now())
|
||||
|
||||
b.logger.Trace("plugin.SpecialPaths", "status", "started", "type", b.typeStr, "transport", b.transport)
|
||||
b.logger.Trace("special paths", "status", "started")
|
||||
return b.next.SpecialPaths()
|
||||
}
|
||||
|
||||
|
@ -49,45 +47,45 @@ func (b *backendTracingMiddleware) Logger() log.Logger {
|
|||
|
||||
func (b *backendTracingMiddleware) HandleExistenceCheck(ctx context.Context, req *logical.Request) (found bool, exists bool, err error) {
|
||||
defer func(then time.Time) {
|
||||
b.logger.Trace("plugin.HandleExistenceCheck", "path", req.Path, "status", "finished", "type", b.typeStr, "transport", b.transport, "err", err, "took", time.Since(then))
|
||||
b.logger.Trace("handle existence check", "path", req.Path, "status", "finished", "err", err, "took", time.Since(then))
|
||||
}(time.Now())
|
||||
|
||||
b.logger.Trace("plugin.HandleExistenceCheck", "path", req.Path, "status", "started", "type", b.typeStr, "transport", b.transport)
|
||||
b.logger.Trace("handle existence check", "path", req.Path, "status", "started")
|
||||
return b.next.HandleExistenceCheck(ctx, req)
|
||||
}
|
||||
|
||||
func (b *backendTracingMiddleware) Cleanup(ctx context.Context) {
|
||||
defer func(then time.Time) {
|
||||
b.logger.Trace("plugin.Cleanup", "status", "finished", "type", b.typeStr, "transport", b.transport, "took", time.Since(then))
|
||||
b.logger.Trace("cleanup", "status", "finished", "took", time.Since(then))
|
||||
}(time.Now())
|
||||
|
||||
b.logger.Trace("plugin.Cleanup", "status", "started", "type", b.typeStr, "transport", b.transport)
|
||||
b.logger.Trace("cleanup", "status", "started")
|
||||
b.next.Cleanup(ctx)
|
||||
}
|
||||
|
||||
func (b *backendTracingMiddleware) InvalidateKey(ctx context.Context, key string) {
|
||||
defer func(then time.Time) {
|
||||
b.logger.Trace("plugin.InvalidateKey", "key", key, "status", "finished", "type", b.typeStr, "transport", b.transport, "took", time.Since(then))
|
||||
b.logger.Trace("invalidate key", "key", key, "status", "finished", "took", time.Since(then))
|
||||
}(time.Now())
|
||||
|
||||
b.logger.Trace("plugin.InvalidateKey", "key", key, "status", "started", "type", b.typeStr, "transport", b.transport)
|
||||
b.logger.Trace("invalidate key", "key", key, "status", "started")
|
||||
b.next.InvalidateKey(ctx, key)
|
||||
}
|
||||
|
||||
func (b *backendTracingMiddleware) Setup(ctx context.Context, config *logical.BackendConfig) (err error) {
|
||||
defer func(then time.Time) {
|
||||
b.logger.Trace("plugin.Setup", "status", "finished", "type", b.typeStr, "transport", b.transport, "err", err, "took", time.Since(then))
|
||||
b.logger.Trace("setup", "status", "finished", "err", err, "took", time.Since(then))
|
||||
}(time.Now())
|
||||
|
||||
b.logger.Trace("plugin.Setup", "status", "started", "type", b.typeStr, "transport", b.transport)
|
||||
b.logger.Trace("setup", "status", "started")
|
||||
return b.next.Setup(ctx, config)
|
||||
}
|
||||
|
||||
func (b *backendTracingMiddleware) Type() logical.BackendType {
|
||||
defer func(then time.Time) {
|
||||
b.logger.Trace("plugin.Type", "status", "finished", "type", b.typeStr, "transport", b.transport, "took", time.Since(then))
|
||||
b.logger.Trace("type", "status", "finished", "took", time.Since(then))
|
||||
}(time.Now())
|
||||
|
||||
b.logger.Trace("plugin.Type", "status", "started", "type", b.typeStr, "transport", b.transport)
|
||||
b.logger.Trace("type", "status", "started")
|
||||
return b.next.Type()
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ import (
|
|||
|
||||
"sync"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/vault/helper/pluginutil"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
// init registers basic structs with gob which will be used to transport complex
|
||||
|
@ -101,12 +101,14 @@ func newPluginClient(ctx context.Context, sys pluginutil.RunnerUtil, pluginRunne
|
|||
},
|
||||
}
|
||||
|
||||
namedLogger := logger.Named(pluginRunner.Name)
|
||||
|
||||
var client *plugin.Client
|
||||
var err error
|
||||
if isMetadataMode {
|
||||
client, err = pluginRunner.RunMetadataMode(ctx, sys, pluginMap, handshakeConfig, []string{}, logger)
|
||||
client, err = pluginRunner.RunMetadataMode(ctx, sys, pluginMap, handshakeConfig, []string{}, namedLogger)
|
||||
} else {
|
||||
client, err = pluginRunner.Run(ctx, sys, pluginMap, handshakeConfig, []string{}, logger)
|
||||
client, err = pluginRunner.Run(ctx, sys, pluginMap, handshakeConfig, []string{}, namedLogger)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -140,12 +142,10 @@ func newPluginClient(ctx context.Context, sys pluginutil.RunnerUtil, pluginRunne
|
|||
}
|
||||
|
||||
// Wrap the backend in a tracing middleware
|
||||
if logger.IsTrace() {
|
||||
if namedLogger.IsTrace() {
|
||||
backend = &backendTracingMiddleware{
|
||||
logger: logger,
|
||||
transport: transport,
|
||||
typeStr: pluginRunner.Name,
|
||||
next: backend,
|
||||
logger: namedLogger.With("transport", transport),
|
||||
next: backend,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"crypto/tls"
|
||||
"os"
|
||||
|
||||
hclog "github.com/hashicorp/go-hclog"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/go-plugin"
|
||||
"github.com/hashicorp/vault/helper/pluginutil"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
|
@ -19,7 +19,7 @@ type TLSProviderFunc func() (*tls.Config, error)
|
|||
type ServeOpts struct {
|
||||
BackendFactoryFunc logical.Factory
|
||||
TLSProviderFunc TLSProviderFunc
|
||||
Logger hclog.Logger
|
||||
Logger log.Logger
|
||||
}
|
||||
|
||||
// Serve is a helper function used to serve a backend plugin. This
|
||||
|
@ -27,8 +27,8 @@ type ServeOpts struct {
|
|||
func Serve(opts *ServeOpts) error {
|
||||
logger := opts.Logger
|
||||
if logger == nil {
|
||||
logger = hclog.New(&hclog.LoggerOptions{
|
||||
Level: hclog.Trace,
|
||||
logger = log.New(&log.LoggerOptions{
|
||||
Level: log.Trace,
|
||||
Output: os.Stderr,
|
||||
JSONFormat: true,
|
||||
})
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
)
|
||||
|
||||
// TestRequest is a helper to create a purely in-memory Request struct.
|
||||
|
@ -76,10 +76,9 @@ func TestSystemView() *StaticSystemView {
|
|||
|
||||
func TestBackendConfig() *BackendConfig {
|
||||
bc := &BackendConfig{
|
||||
Logger: logformat.NewVaultLogger(log.LevelTrace),
|
||||
Logger: logging.NewVaultLogger(log.Trace),
|
||||
System: TestSystemView(),
|
||||
}
|
||||
bc.Logger.SetLevel(log.LevelTrace)
|
||||
|
||||
return bc
|
||||
}
|
||||
|
|
|
@ -9,11 +9,11 @@ import (
|
|||
"sort"
|
||||
"testing"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/hashicorp/errwrap"
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/physical/inmem"
|
||||
|
@ -135,7 +135,7 @@ func Test(tt TestT, c TestCase) {
|
|||
}
|
||||
|
||||
// Create an in-memory Vault core
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Trace)
|
||||
|
||||
phys, err := inmem.NewInmem(nil, logger)
|
||||
if err != nil {
|
||||
|
@ -210,8 +210,8 @@ func Test(tt TestT, c TestCase) {
|
|||
// Make requests
|
||||
var revoke []*logical.Request
|
||||
for i, s := range c.Steps {
|
||||
if log.IsWarn() {
|
||||
log.Warn("Executing test step", "step_number", i+1)
|
||||
if logger.IsWarn() {
|
||||
logger.Warn("Executing test step", "step_number", i+1)
|
||||
}
|
||||
|
||||
// Create the request
|
||||
|
@ -294,8 +294,8 @@ func Test(tt TestT, c TestCase) {
|
|||
// Revoke any secrets we might have.
|
||||
var failedRevokes []*logical.Secret
|
||||
for _, req := range revoke {
|
||||
if log.IsWarn() {
|
||||
log.Warn("Revoking secret", "secret", fmt.Sprintf("%#v", req))
|
||||
if logger.IsWarn() {
|
||||
logger.Warn("Revoking secret", "secret", fmt.Sprintf("%#v", req))
|
||||
}
|
||||
req.ClientToken = client.Token()
|
||||
resp, err := core.HandleRequest(req)
|
||||
|
@ -311,7 +311,7 @@ func Test(tt TestT, c TestCase) {
|
|||
// Perform any rollbacks. This should no-op if there aren't any.
|
||||
// We set the "immediate" flag here that any backend can pick up on
|
||||
// to do all rollbacks immediately even if the WAL entries are new.
|
||||
log.Warn("Requesting RollbackOperation")
|
||||
logger.Warn("Requesting RollbackOperation")
|
||||
req := logical.RollbackRequest(prefix + "/")
|
||||
req.Data["immediate"] = true
|
||||
req.ClientToken = client.Token()
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"time"
|
||||
|
||||
storage "github.com/Azure/azure-sdk-for-go/storage"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/armon/go-metrics"
|
||||
"github.com/hashicorp/errwrap"
|
||||
|
@ -86,7 +86,7 @@ func NewAzureBackend(conf map[string]string, logger log.Logger) (physical.Backen
|
|||
return nil, errwrap.Wrapf("failed parsing max_parallel parameter: {{err}}", err)
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("azure: max_parallel set", "max_parallel", maxParInt)
|
||||
logger.Debug("max_parallel set", "max_parallel", maxParInt)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
"time"
|
||||
|
||||
cleanhttp "github.com/hashicorp/go-cleanhttp"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
|
||||
storage "github.com/Azure/azure-sdk-for-go/storage"
|
||||
)
|
||||
|
@ -29,7 +29,7 @@ func TestAzureBackend(t *testing.T) {
|
|||
cleanupClient, _ := storage.NewBasicClient(accountName, accountKey)
|
||||
cleanupClient.HTTPClient = cleanhttp.DefaultPooledClient()
|
||||
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
backend, err := NewAzureBackend(map[string]string{
|
||||
"container": name,
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"context"
|
||||
"sync/atomic"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/golang-lru"
|
||||
"github.com/hashicorp/vault/helper/locksutil"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -41,8 +41,8 @@ var _ Transactional = (*TransactionalCache)(nil)
|
|||
// NewCache returns a physical cache of the given size.
|
||||
// If no size is provided, the default size is used.
|
||||
func NewCache(b Backend, size int, logger log.Logger) *Cache {
|
||||
if logger.IsTrace() {
|
||||
logger.Trace("physical/cache: creating LRU cache", "size", size)
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("creating LRU cache", "size", size)
|
||||
}
|
||||
if size <= 0 {
|
||||
size = DefaultCacheSize
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/armon/go-metrics"
|
||||
"github.com/gocql/gocql"
|
||||
|
@ -145,7 +145,8 @@ func NewCassandraBackend(conf map[string]string, logger log.Logger) (physical.Ba
|
|||
impl := &CassandraBackend{
|
||||
sess: sess,
|
||||
table: table,
|
||||
logger: logger}
|
||||
logger: logger,
|
||||
}
|
||||
return impl, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/gocql/gocql"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
dockertest "gopkg.in/ory-am/dockertest.v3"
|
||||
)
|
||||
|
||||
|
@ -24,7 +24,7 @@ func TestCassandraBackend(t *testing.T) {
|
|||
defer cleanup()
|
||||
|
||||
// Run vault tests
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
b, err := NewCassandraBackend(map[string]string{
|
||||
"hosts": hosts,
|
||||
"protocol_version": "3",
|
||||
|
|
|
@ -12,9 +12,9 @@ import (
|
|||
"github.com/armon/go-metrics"
|
||||
"github.com/cockroachdb/cockroach-go/crdb"
|
||||
"github.com/hashicorp/errwrap"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/strutil"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
|
||||
// CockroachDB uses the Postgres SQL driver
|
||||
_ "github.com/lib/pq"
|
||||
|
@ -58,7 +58,7 @@ func NewCockroachDBBackend(conf map[string]string, logger log.Logger) (physical.
|
|||
return nil, errwrap.Wrapf("failed parsing max_parallel parameter: {{err}}", err)
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("cockroachdb: max_parallel set", "max_parallel", maxParInt)
|
||||
logger.Debug("max_parallel set", "max_parallel", maxParInt)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
|
||||
dockertest "gopkg.in/ory-am/dockertest.v3"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
@ -72,7 +72,7 @@ func TestCockroachDBBackend(t *testing.T) {
|
|||
defer cleanup()
|
||||
|
||||
// Run vault tests
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
b, err := NewCockroachDBBackend(map[string]string{
|
||||
"connection_url": connURL,
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
"golang.org/x/net/http2"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
|
@ -110,16 +110,16 @@ func NewConsulBackend(conf map[string]string, logger log.Logger) (physical.Backe
|
|||
path = "vault/"
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("physical/consul: config path set", "path", path)
|
||||
logger.Debug("config path set", "path", path)
|
||||
}
|
||||
|
||||
// Ensure path is suffixed but not prefixed
|
||||
if !strings.HasSuffix(path, "/") {
|
||||
logger.Warn("physical/consul: appending trailing forward slash to path")
|
||||
logger.Warn("appending trailing forward slash to path")
|
||||
path += "/"
|
||||
}
|
||||
if strings.HasPrefix(path, "/") {
|
||||
logger.Warn("physical/consul: trimming path of its forward slash")
|
||||
logger.Warn("trimming path of its forward slash")
|
||||
path = strings.TrimPrefix(path, "/")
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ func NewConsulBackend(conf map[string]string, logger log.Logger) (physical.Backe
|
|||
disableRegistration = b
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("physical/consul: config disable_registration set", "disable_registration", disableRegistration)
|
||||
logger.Debug("config disable_registration set", "disable_registration", disableRegistration)
|
||||
}
|
||||
|
||||
// Get the service name to advertise in Consul
|
||||
|
@ -146,13 +146,13 @@ func NewConsulBackend(conf map[string]string, logger log.Logger) (physical.Backe
|
|||
return nil, errors.New("service name must be valid per RFC 1123 and can contain only alphanumeric characters or dashes")
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("physical/consul: config service set", "service", service)
|
||||
logger.Debug("config service set", "service", service)
|
||||
}
|
||||
|
||||
// Get the additional tags to attach to the registered service name
|
||||
tags := conf["service_tags"]
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("physical/consul: config service_tags set", "service_tags", tags)
|
||||
logger.Debug("config service_tags set", "service_tags", tags)
|
||||
}
|
||||
|
||||
// Get the service-specific address to override the use of the HA redirect address
|
||||
|
@ -162,7 +162,7 @@ func NewConsulBackend(conf map[string]string, logger log.Logger) (physical.Backe
|
|||
serviceAddr = &serviceAddrStr
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("physical/consul: config service_address set", "service_address", serviceAddr)
|
||||
logger.Debug("config service_address set", "service_address", serviceAddr)
|
||||
}
|
||||
|
||||
checkTimeout := defaultCheckTimeout
|
||||
|
@ -180,7 +180,7 @@ func NewConsulBackend(conf map[string]string, logger log.Logger) (physical.Backe
|
|||
|
||||
checkTimeout = d
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("physical/consul: config check_timeout set", "check_timeout", d)
|
||||
logger.Debug("config check_timeout set", "check_timeout", d)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,18 +192,18 @@ func NewConsulBackend(conf map[string]string, logger log.Logger) (physical.Backe
|
|||
if addr, ok := conf["address"]; ok {
|
||||
consulConf.Address = addr
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("physical/consul: config address set", "address", addr)
|
||||
logger.Debug("config address set", "address", addr)
|
||||
}
|
||||
}
|
||||
if scheme, ok := conf["scheme"]; ok {
|
||||
consulConf.Scheme = scheme
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("physical/consul: config scheme set", "scheme", scheme)
|
||||
logger.Debug("config scheme set", "scheme", scheme)
|
||||
}
|
||||
}
|
||||
if token, ok := conf["token"]; ok {
|
||||
consulConf.Token = token
|
||||
logger.Debug("physical/consul: config token set")
|
||||
logger.Debug("config token set")
|
||||
}
|
||||
|
||||
if consulConf.Scheme == "https" {
|
||||
|
@ -216,7 +216,7 @@ func NewConsulBackend(conf map[string]string, logger log.Logger) (physical.Backe
|
|||
if err := http2.ConfigureTransport(consulConf.Transport); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logger.Debug("physical/consul: configured TLS")
|
||||
logger.Debug("configured TLS")
|
||||
}
|
||||
|
||||
consulConf.HttpClient = &http.Client{Transport: consulConf.Transport}
|
||||
|
@ -233,7 +233,7 @@ func NewConsulBackend(conf map[string]string, logger log.Logger) (physical.Backe
|
|||
return nil, errwrap.Wrapf("failed parsing max_parallel parameter: {{err}}", err)
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("physical/consul: max_parallel set", "max_parallel", maxParInt)
|
||||
logger.Debug("max_parallel set", "max_parallel", maxParInt)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -544,7 +544,7 @@ func (c *ConsulBackend) NotifyActiveStateChange() error {
|
|||
default:
|
||||
// NOTE: If this occurs Vault's active status could be out of
|
||||
// sync with Consul until reconcileTimer expires.
|
||||
c.logger.Warn("physical/consul: Concurrent state change notify dropped")
|
||||
c.logger.Warn("concurrent state change notify dropped")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -556,7 +556,7 @@ func (c *ConsulBackend) NotifySealedStateChange() error {
|
|||
default:
|
||||
// NOTE: If this occurs Vault's sealed status could be out of
|
||||
// sync with Consul until checkTimer expires.
|
||||
c.logger.Warn("physical/consul: Concurrent sealed state change notify dropped")
|
||||
c.logger.Warn("concurrent sealed state change notify dropped")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -629,7 +629,7 @@ func (c *ConsulBackend) runEventDemuxer(waitGroup *sync.WaitGroup, shutdownCh ph
|
|||
serviceID, err := c.reconcileConsul(registeredServiceID, activeFunc, sealedFunc)
|
||||
if err != nil {
|
||||
if c.logger.IsWarn() {
|
||||
c.logger.Warn("physical/consul: reconcile unable to talk with Consul backend", "error", err)
|
||||
c.logger.Warn("reconcile unable to talk with Consul backend", "error", err)
|
||||
}
|
||||
time.Sleep(consulRetryInterval)
|
||||
continue
|
||||
|
@ -655,7 +655,7 @@ func (c *ConsulBackend) runEventDemuxer(waitGroup *sync.WaitGroup, shutdownCh ph
|
|||
sealed := sealedFunc()
|
||||
if err := c.runCheck(sealed); err != nil {
|
||||
if c.logger.IsWarn() {
|
||||
c.logger.Warn("physical/consul: check unable to talk with Consul backend", "error", err)
|
||||
c.logger.Warn("check unable to talk with Consul backend", "error", err)
|
||||
}
|
||||
time.Sleep(consulRetryInterval)
|
||||
continue
|
||||
|
@ -665,7 +665,7 @@ func (c *ConsulBackend) runEventDemuxer(waitGroup *sync.WaitGroup, shutdownCh ph
|
|||
}()
|
||||
}
|
||||
case <-shutdownCh:
|
||||
c.logger.Info("physical/consul: Shutting down consul backend")
|
||||
c.logger.Info("shutting down consul backend")
|
||||
shutdown = true
|
||||
}
|
||||
}
|
||||
|
@ -674,7 +674,7 @@ func (c *ConsulBackend) runEventDemuxer(waitGroup *sync.WaitGroup, shutdownCh ph
|
|||
defer c.serviceLock.RUnlock()
|
||||
if err := c.client.Agent().ServiceDeregister(registeredServiceID); err != nil {
|
||||
if c.logger.IsWarn() {
|
||||
c.logger.Warn("physical/consul: service deregistration failed", "error", err)
|
||||
c.logger.Warn("service deregistration failed", "error", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,10 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/hashicorp/consul/api"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/helper/strutil"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
dockertest "gopkg.in/ory-am/dockertest.v2"
|
||||
|
@ -36,7 +36,7 @@ func testConsulBackend(t *testing.T) *ConsulBackend {
|
|||
}
|
||||
|
||||
func testConsulBackendConfig(t *testing.T, conf *consulConf) *ConsulBackend {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
be, err := NewConsulBackend(*conf, logger)
|
||||
if err != nil {
|
||||
|
@ -93,7 +93,7 @@ func TestConsul_ServiceTags(t *testing.T) {
|
|||
"max_parallel": "4",
|
||||
"disable_registration": "false",
|
||||
}
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
be, err := NewConsulBackend(consulConfig, logger)
|
||||
if err != nil {
|
||||
|
@ -138,7 +138,7 @@ func TestConsul_ServiceAddress(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
be, err := NewConsulBackend(test.consulConfig, logger)
|
||||
if err != nil {
|
||||
|
@ -226,7 +226,7 @@ func TestConsul_newConsulBackend(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
be, err := NewConsulBackend(test.consulConfig, logger)
|
||||
if test.fail {
|
||||
|
@ -425,7 +425,7 @@ func TestConsul_serviceID(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
for _, test := range tests {
|
||||
be, err := NewConsulBackend(consulConf{
|
||||
|
@ -482,7 +482,7 @@ func TestConsulBackend(t *testing.T) {
|
|||
client.KV().DeleteTree(randPath, nil)
|
||||
}()
|
||||
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
b, err := NewConsulBackend(map[string]string{
|
||||
"address": conf.Address,
|
||||
|
@ -523,7 +523,7 @@ func TestConsulHABackend(t *testing.T) {
|
|||
client.KV().DeleteTree(randPath, nil)
|
||||
}()
|
||||
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
b, err := NewConsulBackend(map[string]string{
|
||||
"address": conf.Address,
|
||||
|
|
|
@ -16,8 +16,8 @@ import (
|
|||
"github.com/armon/go-metrics"
|
||||
"github.com/hashicorp/errwrap"
|
||||
cleanhttp "github.com/hashicorp/go-cleanhttp"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
// CouchDBBackend allows the management of couchdb users
|
||||
|
@ -177,7 +177,7 @@ func buildCouchDBBackend(conf map[string]string, logger log.Logger) (*CouchDBBac
|
|||
return nil, errwrap.Wrapf("failed parsing max_parallel parameter: {{err}}", err)
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("couchdb: max_parallel set", "max_parallel", maxParInt)
|
||||
logger.Debug("max_parallel set", "max_parallel", maxParInt)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
dockertest "gopkg.in/ory-am/dockertest.v3"
|
||||
)
|
||||
|
||||
|
@ -19,7 +19,7 @@ func TestCouchDBBackend(t *testing.T) {
|
|||
cleanup, endpoint, username, password := prepareCouchdbDBTestContainer(t)
|
||||
defer cleanup()
|
||||
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
b, err := NewCouchDBBackend(map[string]string{
|
||||
"endpoint": endpoint,
|
||||
|
@ -38,7 +38,7 @@ func TestTransactionalCouchDBBackend(t *testing.T) {
|
|||
cleanup, endpoint, username, password := prepareCouchdbDBTestContainer(t)
|
||||
defer cleanup()
|
||||
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
b, err := NewTransactionalCouchDBBackend(map[string]string{
|
||||
"endpoint": endpoint,
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/armon/go-metrics"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
dockertest "gopkg.in/ory-am/dockertest.v3"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
|
@ -48,7 +48,7 @@ func TestDynamoDBBackend(t *testing.T) {
|
|||
})
|
||||
}()
|
||||
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
b, err := NewDynamoDBBackend(map[string]string{
|
||||
"access_key": creds.AccessKeyID,
|
||||
|
@ -95,7 +95,7 @@ func TestDynamoDBHABackend(t *testing.T) {
|
|||
})
|
||||
}()
|
||||
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
b, err := NewDynamoDBBackend(map[string]string{
|
||||
"access_key": creds.AccessKeyID,
|
||||
"secret_key": creds.SecretAccessKey,
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
|
||||
"github.com/coreos/etcd/client"
|
||||
"github.com/coreos/go-semver/semver"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -14,8 +14,8 @@ import (
|
|||
metrics "github.com/armon/go-metrics"
|
||||
"github.com/coreos/etcd/client"
|
||||
"github.com/coreos/etcd/pkg/transport"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -14,9 +14,9 @@ import (
|
|||
"github.com/coreos/etcd/clientv3"
|
||||
"github.com/coreos/etcd/clientv3/concurrency"
|
||||
"github.com/coreos/etcd/pkg/transport"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/strutil"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
func TestEtcd3Backend(t *testing.T) {
|
||||
|
@ -17,7 +17,7 @@ func TestEtcd3Backend(t *testing.T) {
|
|||
t.Skipf("Skipped. No etcd3 server found")
|
||||
}
|
||||
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
b, err := NewEtcdBackend(map[string]string{
|
||||
"path": fmt.Sprintf("/vault-%d", time.Now().Unix()),
|
||||
|
|
|
@ -6,9 +6,9 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
|
||||
"github.com/coreos/etcd/client"
|
||||
"golang.org/x/net/context"
|
||||
|
@ -51,7 +51,7 @@ func TestEtcdBackend(t *testing.T) {
|
|||
|
||||
// Generate new etcd backend. The etcd address is read from ETCD_ADDR. No
|
||||
// need to provide it explicitly.
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
b, err := NewEtcdBackend(map[string]string{
|
||||
"path": randPath,
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/hashicorp/vault/helper/consts"
|
||||
"github.com/hashicorp/vault/helper/jsonutil"
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
func TestFileBackend_Base64URLEncoding(t *testing.T) {
|
||||
|
@ -21,7 +21,7 @@ func TestFileBackend_Base64URLEncoding(t *testing.T) {
|
|||
}
|
||||
defer os.RemoveAll(backendPath)
|
||||
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
b, err := NewFileBackend(map[string]string{
|
||||
"path": backendPath,
|
||||
|
@ -140,7 +140,7 @@ func TestFileBackend_ValidatePath(t *testing.T) {
|
|||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
b, err := NewFileBackend(map[string]string{
|
||||
"path": dir,
|
||||
|
@ -164,7 +164,7 @@ func TestFileBackend(t *testing.T) {
|
|||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
b, err := NewFileBackend(map[string]string{
|
||||
"path": dir,
|
||||
|
|
|
@ -11,9 +11,9 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/hashicorp/errwrap"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/useragent"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
|
||||
"cloud.google.com/go/storage"
|
||||
"github.com/armon/go-metrics"
|
||||
|
@ -108,6 +108,7 @@ func NewBackend(c map[string]string, logger log.Logger) (physical.Backend, error
|
|||
if err != nil {
|
||||
return nil, errwrap.Wrapf("failed to parse chunk_size: {{err}}", err)
|
||||
}
|
||||
|
||||
// Values are specified as kb, but the API expects them as bytes.
|
||||
chunkSize = chunkSize * 1024
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"time"
|
||||
|
||||
"cloud.google.com/go/storage"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
|
@ -40,7 +40,7 @@ func TestHABackend(t *testing.T) {
|
|||
backend, err := NewBackend(map[string]string{
|
||||
"bucket": bucket,
|
||||
"ha_enabled": "true",
|
||||
}, logformat.NewVaultLogger(log.LevelTrace))
|
||||
}, logging.NewVaultLogger(log.Trace))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"time"
|
||||
|
||||
"cloud.google.com/go/storage"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/api/googleapi"
|
||||
)
|
||||
|
@ -52,7 +52,7 @@ func TestBackend(t *testing.T) {
|
|||
backend, err := NewBackend(map[string]string{
|
||||
"bucket": bucket,
|
||||
"ha_enabled": "false",
|
||||
}, logformat.NewVaultLogger(log.LevelTrace))
|
||||
}, logging.NewVaultLogger(log.Trace))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@ import (
|
|||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
func TestCache(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
inm, err := NewInmem(nil, logger)
|
||||
if err != nil {
|
||||
|
@ -22,7 +22,7 @@ func TestCache(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCache_Purge(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
inm, err := NewInmem(nil, logger)
|
||||
if err != nil {
|
||||
|
@ -69,7 +69,7 @@ func TestCache_Purge(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCache_Disable(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
inm, err := NewInmem(nil, logger)
|
||||
if err != nil {
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
|
||||
"github.com/armon/go-radix"
|
||||
)
|
||||
|
|
|
@ -4,8 +4,8 @@ import (
|
|||
"fmt"
|
||||
"sync"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
type InmemHABackend struct {
|
||||
|
|
|
@ -3,13 +3,13 @@ package inmem
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
func TestInmemHA(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
inm, err := NewInmemHA(nil, logger)
|
||||
if err != nil {
|
||||
|
|
|
@ -3,13 +3,13 @@ package inmem
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
func TestInmem(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
inm, err := NewInmem(nil, logger)
|
||||
if err != nil {
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
func TestPhysicalView_impl(t *testing.T) {
|
||||
|
@ -14,7 +14,7 @@ func TestPhysicalView_impl(t *testing.T) {
|
|||
}
|
||||
|
||||
func newInmemTestBackend() (physical.Backend, error) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
return NewInmem(nil, logger)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"testing"
|
||||
|
||||
radix "github.com/armon/go-radix"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
type faultyPseudo struct {
|
||||
|
@ -70,7 +70,7 @@ func newFaultyPseudo(logger log.Logger, faultyPaths []string) *faultyPseudo {
|
|||
underlying: InmemBackend{
|
||||
root: radix.New(),
|
||||
permitPool: physical.NewPermitPool(1),
|
||||
logger: logger,
|
||||
logger: logger.Named("storage.inmembackend"),
|
||||
},
|
||||
faultyPaths: make(map[string]struct{}, len(faultyPaths)),
|
||||
}
|
||||
|
@ -81,21 +81,21 @@ func newFaultyPseudo(logger log.Logger, faultyPaths []string) *faultyPseudo {
|
|||
}
|
||||
|
||||
func TestPseudo_Basic(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
p := newFaultyPseudo(logger, nil)
|
||||
physical.ExerciseBackend(t, p)
|
||||
physical.ExerciseBackend_ListPrefix(t, p)
|
||||
}
|
||||
|
||||
func TestPseudo_SuccessfulTransaction(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
p := newFaultyPseudo(logger, nil)
|
||||
|
||||
physical.ExerciseTransactionalBackend(t, p)
|
||||
}
|
||||
|
||||
func TestPseudo_FailedTransaction(t *testing.T) {
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
p := newFaultyPseudo(logger, []string{"zip"})
|
||||
|
||||
txns := physical.SetupTestingTransactions(t, p)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"math/rand"
|
||||
"time"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -37,7 +37,7 @@ func NewLatencyInjector(b Backend, latency time.Duration, jitter int, logger log
|
|||
if jitter < 0 || jitter > 100 {
|
||||
jitter = DefaultJitterPercent
|
||||
}
|
||||
logger.Info("physical/latency: creating latency injector")
|
||||
logger.Info("creating latency injector")
|
||||
|
||||
return &LatencyInjector{
|
||||
backend: b,
|
||||
|
|
|
@ -14,12 +14,12 @@ import (
|
|||
|
||||
"github.com/armon/go-metrics"
|
||||
"github.com/hashicorp/errwrap"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
"github.com/joyent/triton-go"
|
||||
"github.com/joyent/triton-go/authentication"
|
||||
"github.com/joyent/triton-go/errors"
|
||||
"github.com/joyent/triton-go/storage"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
const mantaDefaultRootStore = "/stor"
|
||||
|
@ -74,7 +74,7 @@ func NewMantaBackend(conf map[string]string, logger log.Logger) (physical.Backen
|
|||
return nil, errwrap.Wrapf("failed parsing max_parallel parameter: {{err}}", err)
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("manta: max_parallel set", "max_parallel", maxParInt)
|
||||
logger.Debug("max_parallel set", "max_parallel", maxParInt)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,13 +9,13 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
"github.com/joyent/triton-go"
|
||||
"github.com/joyent/triton-go/authentication"
|
||||
tt "github.com/joyent/triton-go/errors"
|
||||
"github.com/joyent/triton-go/storage"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
func TestMantaBackend(t *testing.T) {
|
||||
|
@ -49,11 +49,11 @@ func TestMantaBackend(t *testing.T) {
|
|||
t.Fatalf("failed initialising Storage client: %s", err.Error())
|
||||
}
|
||||
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
mb := &MantaBackend{
|
||||
client: client,
|
||||
directory: testHarnessBucket,
|
||||
logger: logger,
|
||||
logger: logger.Named("storage.mantabackend"),
|
||||
permitPool: physical.NewPermitPool(128),
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ import (
|
|||
"github.com/armon/go-metrics"
|
||||
_ "github.com/denisenkom/go-mssqldb"
|
||||
"github.com/hashicorp/errwrap"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/strutil"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
)
|
||||
|
||||
// Verify MSSQLBackend satisfies the correct interfaces
|
||||
|
@ -53,7 +53,7 @@ func NewMSSQLBackend(conf map[string]string, logger log.Logger) (physical.Backen
|
|||
return nil, errwrap.Wrapf("failed parsing max_parallel parameter: {{err}}", err)
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("mysql: max_parallel set", "max_parallel", maxParInt)
|
||||
logger.Debug("max_parallel set", "max_parallel", maxParInt)
|
||||
}
|
||||
} else {
|
||||
maxParInt = physical.DefaultParallelOperations
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
|
||||
_ "github.com/denisenkom/go-mssqldb"
|
||||
)
|
||||
|
@ -31,7 +31,7 @@ func TestMSSQLBackend(t *testing.T) {
|
|||
password := os.Getenv("MSSQL_PASSWORD")
|
||||
|
||||
// Run vault tests
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
b, err := NewMSSQLBackend(map[string]string{
|
||||
"server": server,
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/armon/go-metrics"
|
||||
mysql "github.com/go-sql-driver/mysql"
|
||||
|
@ -79,7 +79,7 @@ func NewMySQLBackend(conf map[string]string, logger log.Logger) (physical.Backen
|
|||
return nil, errwrap.Wrapf("failed parsing max_idle_connections parameter: {{err}}", err)
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("mysql: max_idle_connections set", "max_idle_connections", maxIdleConnInt)
|
||||
logger.Debug("max_idle_connections set", "max_idle_connections", maxIdleConnInt)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ func NewMySQLBackend(conf map[string]string, logger log.Logger) (physical.Backen
|
|||
return nil, errwrap.Wrapf("failed parsing max_connection_lifetime parameter: {{err}}", err)
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("mysql: max_connection_lifetime set", "max_connection_lifetime", maxConnLifeInt)
|
||||
logger.Debug("max_connection_lifetime set", "max_connection_lifetime", maxConnLifeInt)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ func NewMySQLBackend(conf map[string]string, logger log.Logger) (physical.Backen
|
|||
return nil, errwrap.Wrapf("failed parsing max_parallel parameter: {{err}}", err)
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("mysql: max_parallel set", "max_parallel", maxParInt)
|
||||
logger.Debug("max_parallel set", "max_parallel", maxParInt)
|
||||
}
|
||||
} else {
|
||||
maxParInt = physical.DefaultParallelOperations
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
)
|
||||
|
@ -31,7 +31,7 @@ func TestMySQLBackend(t *testing.T) {
|
|||
password := os.Getenv("MYSQL_PASSWORD")
|
||||
|
||||
// Run vault tests
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
b, err := NewMySQLBackend(map[string]string{
|
||||
"address": address,
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
)
|
||||
|
||||
const DefaultParallelOperations = 128
|
||||
|
|
|
@ -10,7 +10,8 @@ import (
|
|||
|
||||
"github.com/hashicorp/errwrap"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
//log "github.com/hashicorp/go-hclog"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/armon/go-metrics"
|
||||
"github.com/lib/pq"
|
||||
|
@ -56,7 +57,7 @@ func NewPostgreSQLBackend(conf map[string]string, logger log.Logger) (physical.B
|
|||
return nil, errwrap.Wrapf("failed parsing max_parallel parameter: {{err}}", err)
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("postgres: max_parallel set", "max_parallel", maxParInt)
|
||||
logger.Debug("max_parallel set", "max_parallel", maxParInt)
|
||||
}
|
||||
} else {
|
||||
maxParInt = physical.DefaultParallelOperations
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
@ -23,7 +23,7 @@ func TestPostgreSQLBackend(t *testing.T) {
|
|||
}
|
||||
|
||||
// Run vault tests
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
b, err := NewPostgreSQLBackend(map[string]string{
|
||||
"connection_url": connURL,
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/armon/go-metrics"
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
|
@ -131,7 +131,7 @@ func NewS3Backend(conf map[string]string, logger log.Logger) (physical.Backend,
|
|||
return nil, errwrap.Wrapf("failed parsing max_parallel parameter: {{err}}", err)
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("s3: max_parallel set", "max_parallel", maxParInt)
|
||||
logger.Debug("max_parallel set", "max_parallel", maxParInt)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/awsutil"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
|
@ -79,7 +79,7 @@ func TestS3Backend(t *testing.T) {
|
|||
}
|
||||
}()
|
||||
|
||||
logger := logformat.NewVaultLogger(log.LevelTrace)
|
||||
logger := logging.NewVaultLogger(log.Debug)
|
||||
|
||||
// This uses the same logic to find the AWS credentials as we did at the beginning of the test
|
||||
b, err := NewS3Backend(map[string]string{
|
||||
|
|
|
@ -10,10 +10,10 @@ import (
|
|||
|
||||
metrics "github.com/armon/go-metrics"
|
||||
"github.com/hashicorp/errwrap"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/strutil"
|
||||
"github.com/hashicorp/vault/helper/useragent"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
"google.golang.org/api/iterator"
|
||||
"google.golang.org/api/option"
|
||||
"google.golang.org/grpc/codes"
|
||||
|
@ -94,7 +94,7 @@ type Backend struct {
|
|||
// configuration. This uses the official Golang Cloud SDK and therefore supports
|
||||
// specifying credentials via envvars, credential files, etc.
|
||||
func NewBackend(c map[string]string, logger log.Logger) (physical.Backend, error) {
|
||||
logger.Debug("physical/spanner: configuring backend")
|
||||
logger.Debug("configuring backend")
|
||||
|
||||
// Database name
|
||||
database := os.Getenv(envDatabase)
|
||||
|
@ -143,14 +143,14 @@ func NewBackend(c map[string]string, logger log.Logger) (physical.Backend, error
|
|||
return nil, errwrap.Wrapf("failed to parse max_parallel: {{err}}", err)
|
||||
}
|
||||
|
||||
logger.Debug("physical/spanner: configuration",
|
||||
logger.Debug("configuration",
|
||||
"database", database,
|
||||
"table", table,
|
||||
"haEnabled", haEnabled,
|
||||
"haTable", haTable,
|
||||
"maxParallel", maxParallel,
|
||||
)
|
||||
logger.Debug("physical/spanner: creating client")
|
||||
logger.Debug("creating client")
|
||||
|
||||
ctx := context.Background()
|
||||
client, err := spanner.NewClient(ctx, database,
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"testing"
|
||||
|
||||
"cloud.google.com/go/spanner"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
|
@ -43,7 +43,7 @@ func TestHABackend(t *testing.T) {
|
|||
"table": table,
|
||||
"ha_table": haTable,
|
||||
"ha_enabled": "true",
|
||||
}, logformat.NewVaultLogger(log.LevelTrace))
|
||||
}, logging.NewVaultLogger(log.Debug))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ import (
|
|||
"testing"
|
||||
|
||||
"cloud.google.com/go/spanner"
|
||||
"github.com/hashicorp/vault/helper/logformat"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/vault/helper/logging"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
|
@ -46,7 +46,7 @@ func TestBackend(t *testing.T) {
|
|||
"database": database,
|
||||
"table": table,
|
||||
"ha_enabled": "false",
|
||||
}, logformat.NewVaultLogger(log.LevelTrace))
|
||||
}, logging.NewVaultLogger(log.Debug))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
log "github.com/mgutz/logxi/v1"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
|
||||
"github.com/armon/go-metrics"
|
||||
"github.com/hashicorp/errwrap"
|
||||
|
@ -113,7 +113,7 @@ func NewSwiftBackend(conf map[string]string, logger log.Logger) (physical.Backen
|
|||
return nil, errwrap.Wrapf("failed parsing max_parallel parameter: {{err}}", err)
|
||||
}
|
||||
if logger.IsDebug() {
|
||||
logger.Debug("swift: max_parallel set", "max_parallel", maxParInt)
|
||||
logger.Debug("max_parallel set", "max_parallel", maxParInt)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue