Update logging to new structure

This commit is contained in:
Brian Kassouf 2017-04-25 10:24:19 -07:00
parent b52b410a47
commit bed1c17b1e
1 changed files with 10 additions and 10 deletions

View File

@ -25,10 +25,10 @@ func (mw *databaseTracingMiddleware) Type() (string, error) {
func (mw *databaseTracingMiddleware) CreateUser(statements Statements, usernamePrefix string, expiration time.Time) (username string, password string, err error) {
if mw.logger.IsTrace() {
defer func(then time.Time) {
mw.logger.Trace("database/CreateUser: finished", "type", mw.typeStr, "err", err, "took", time.Since(then))
mw.logger.Trace("database", "operation", "CreateUser", "status", "finished", "type", mw.typeStr, "err", err, "took", time.Since(then))
}(time.Now())
mw.logger.Trace("database/CreateUser: starting", "type", mw.typeStr)
mw.logger.Trace("database", "operation", "CreateUser", "status", "started", "type", mw.typeStr)
}
return mw.next.CreateUser(statements, usernamePrefix, expiration)
}
@ -36,10 +36,10 @@ func (mw *databaseTracingMiddleware) CreateUser(statements Statements, usernameP
func (mw *databaseTracingMiddleware) RenewUser(statements Statements, username string, expiration time.Time) (err error) {
if mw.logger.IsTrace() {
defer func(then time.Time) {
mw.logger.Trace("database/RenewUser: finished", "type", mw.typeStr, "err", err, "took", time.Since(then))
mw.logger.Trace("database", "operation", "RenewUser", "status", "finished", "type", mw.typeStr, "err", err, "took", time.Since(then))
}(time.Now())
mw.logger.Trace("database/RenewUser: starting", "type", mw.typeStr)
mw.logger.Trace("database", "operation", "RenewUser", "status", "started", mw.typeStr)
}
return mw.next.RenewUser(statements, username, expiration)
}
@ -47,10 +47,10 @@ func (mw *databaseTracingMiddleware) RenewUser(statements Statements, username s
func (mw *databaseTracingMiddleware) RevokeUser(statements Statements, username string) (err error) {
if mw.logger.IsTrace() {
defer func(then time.Time) {
mw.logger.Trace("database/RevokeUser: finished", "type", mw.typeStr, "err", err, "took", time.Since(then))
mw.logger.Trace("database", "operation", "RevokeUser", "status", "finished", "type", mw.typeStr, "err", err, "took", time.Since(then))
}(time.Now())
mw.logger.Trace("database/RevokeUser: starting", "type", mw.typeStr)
mw.logger.Trace("database", "operation", "RevokeUser", "status", "started", "type", mw.typeStr)
}
return mw.next.RevokeUser(statements, username)
}
@ -58,10 +58,10 @@ func (mw *databaseTracingMiddleware) RevokeUser(statements Statements, username
func (mw *databaseTracingMiddleware) Initialize(conf map[string]interface{}, verifyConnection bool) (err error) {
if mw.logger.IsTrace() {
defer func(then time.Time) {
mw.logger.Trace("database/Initialize: finished", "type", mw.typeStr, "verify", verifyConnection, "err", err, "took", time.Since(then))
mw.logger.Trace("database", "operation", "Initialize", "status", "finished", "type", mw.typeStr, "verify", verifyConnection, "err", err, "took", time.Since(then))
}(time.Now())
mw.logger.Trace("database/Initialize: starting", "type", mw.typeStr)
mw.logger.Trace("database", "operation", "Initialize", "status", "started", "type", mw.typeStr)
}
return mw.next.Initialize(conf, verifyConnection)
}
@ -69,10 +69,10 @@ func (mw *databaseTracingMiddleware) Initialize(conf map[string]interface{}, ver
func (mw *databaseTracingMiddleware) Close() (err error) {
if mw.logger.IsTrace() {
defer func(then time.Time) {
mw.logger.Trace("database/Close: finished", "type", mw.typeStr, "err", err, "took", time.Since(then))
mw.logger.Trace("database", "operation", "Close", "status", "finished", "type", mw.typeStr, "err", err, "took", time.Since(then))
}(time.Now())
mw.logger.Trace("database/Close: starting", "type", mw.typeStr)
mw.logger.Trace("database", "operation", "Close", "status", "started", "type", mw.typeStr)
}
return mw.next.Close()
}