fleet/server/service/logging_scheduled_queries.go
Victor Vrantchan 71def50756 add missing logs to kolide service (#843)
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.
2017-01-09 23:40:21 -05:00

98 lines
2.1 KiB
Go

package service
import (
"time"
"github.com/kolide/kolide-ose/server/kolide"
"golang.org/x/net/context"
)
func (mw loggingMiddleware) GetScheduledQuery(ctx context.Context, id uint) (*kolide.ScheduledQuery, error) {
var (
query *kolide.ScheduledQuery
err error
)
defer func(begin time.Time) {
_ = mw.logger.Log(
"method", "GetScheduledQuery",
"err", err,
"took", time.Since(begin),
)
}(time.Now())
query, err = mw.Service.GetScheduledQuery(ctx, id)
return query, err
}
func (mw loggingMiddleware) GetScheduledQueriesInPack(ctx context.Context, id uint, opts kolide.ListOptions) ([]*kolide.ScheduledQuery, error) {
var (
queries []*kolide.ScheduledQuery
err error
)
defer func(begin time.Time) {
_ = mw.logger.Log(
"method", "GetScheduledQueriesInPack",
"err", err,
"took", time.Since(begin),
)
}(time.Now())
queries, err = mw.Service.GetScheduledQueriesInPack(ctx, id, opts)
return queries, err
}
func (mw loggingMiddleware) ScheduleQuery(ctx context.Context, sq *kolide.ScheduledQuery) (*kolide.ScheduledQuery, error) {
var (
query *kolide.ScheduledQuery
err error
)
defer func(begin time.Time) {
_ = mw.logger.Log(
"method", "ScheduleQuery",
"err", err,
"took", time.Since(begin),
)
}(time.Now())
query, err = mw.Service.ScheduleQuery(ctx, sq)
return query, err
}
func (mw loggingMiddleware) DeleteScheduledQuery(ctx context.Context, id uint) error {
var (
err error
)
defer func(begin time.Time) {
_ = mw.logger.Log(
"method", "DeleteScheduledQuery",
"err", err,
"took", time.Since(begin),
)
}(time.Now())
err = mw.Service.DeleteScheduledQuery(ctx, id)
return err
}
func (mw loggingMiddleware) ModifyScheduledQuery(ctx context.Context, sq *kolide.ScheduledQuery) (*kolide.ScheduledQuery, error) {
var (
query *kolide.ScheduledQuery
err error
)
defer func(begin time.Time) {
_ = mw.logger.Log(
"method", "ModifyScheduledQuery",
"err", err,
"took", time.Since(begin),
)
}(time.Now())
query, err = mw.Service.ModifyScheduledQuery(ctx, sq)
return query, err
}