mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 11:38:02 +00:00
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:
committed by
Brian Kassouf
parent
ecdd877bf4
commit
792d219aa9
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user