mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
6580fe1c5a
- Add logging for new campaigns - Add logging for new query creations/modification/deletion - Add usernames for logs found in labels, options, packs, osquery options, queries and scheduled queries where something is created, modified or deleted
43 lines
913 B
Go
43 lines
913 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/kolide/fleet/server/contexts/viewer"
|
|
"github.com/kolide/fleet/server/kolide"
|
|
)
|
|
|
|
func (mw loggingMiddleware) GetOptionsSpec(ctx context.Context) (spec *kolide.OptionsSpec, err error) {
|
|
defer func(begin time.Time) {
|
|
mw.logger.Log(
|
|
"method", "GetOptionsSpec",
|
|
"err", err,
|
|
"took", time.Since(begin),
|
|
)
|
|
}(time.Now())
|
|
spec, err = mw.Service.GetOptionsSpec(ctx)
|
|
return spec, err
|
|
}
|
|
|
|
func (mw loggingMiddleware) ApplyOptionsSpec(ctx context.Context, spec *kolide.OptionsSpec) (err error) {
|
|
var (
|
|
loggedInUser = "unauthenticated"
|
|
)
|
|
|
|
if vc, ok := viewer.FromContext(ctx); ok {
|
|
|
|
loggedInUser = vc.Username()
|
|
}
|
|
defer func(begin time.Time) {
|
|
mw.logger.Log(
|
|
"method", "ApplyOptionsSpec",
|
|
"err", err,
|
|
"user", loggedInUser,
|
|
"took", time.Since(begin),
|
|
)
|
|
}(time.Now())
|
|
err = mw.Service.ApplyOptionsSpec(ctx, spec)
|
|
return err
|
|
}
|