mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
71def50756
Add logging middleware for more of the kolide Service interfaces. This PR was created through code generation, however it's not likely that the logging middleware can all be continuously regenerated - we're likely to want to add method specific key/values to individual methods. Moving forward, logging middleware should be maintained when changes are made to a service interface method.
63 lines
1.2 KiB
Go
63 lines
1.2 KiB
Go
package service
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/kolide/kolide-ose/server/kolide"
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
func (mw loggingMiddleware) NewAppConfig(ctx context.Context, p kolide.AppConfigPayload) (*kolide.AppConfig, error) {
|
|
var (
|
|
info *kolide.AppConfig
|
|
err error
|
|
)
|
|
|
|
defer func(begin time.Time) {
|
|
_ = mw.logger.Log(
|
|
"method", "NewAppConfig",
|
|
"err", err,
|
|
"took", time.Since(begin),
|
|
)
|
|
}(time.Now())
|
|
|
|
info, err = mw.Service.NewAppConfig(ctx, p)
|
|
return info, err
|
|
}
|
|
|
|
func (mw loggingMiddleware) AppConfig(ctx context.Context) (*kolide.AppConfig, error) {
|
|
var (
|
|
info *kolide.AppConfig
|
|
err error
|
|
)
|
|
|
|
defer func(begin time.Time) {
|
|
_ = mw.logger.Log(
|
|
"method", "AppConfig",
|
|
"err", err,
|
|
"took", time.Since(begin),
|
|
)
|
|
}(time.Now())
|
|
|
|
info, err = mw.Service.AppConfig(ctx)
|
|
return info, err
|
|
}
|
|
|
|
func (mw loggingMiddleware) ModifyAppConfig(ctx context.Context, p kolide.AppConfigPayload) (*kolide.AppConfig, error) {
|
|
var (
|
|
info *kolide.AppConfig
|
|
err error
|
|
)
|
|
|
|
defer func(begin time.Time) {
|
|
_ = mw.logger.Log(
|
|
"method", "ModifyAppConfig",
|
|
"err", err,
|
|
"took", time.Since(begin),
|
|
)
|
|
}(time.Now())
|
|
|
|
info, err = mw.Service.ModifyAppConfig(ctx, p)
|
|
return info, err
|
|
}
|