Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
pulak-opti committed Nov 23, 2023
1 parent 2204260 commit 12773d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cmd/optimizely/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/spf13/viper"

"github.com/optimizely/agent/config"
"github.com/optimizely/agent/pkg/handlers"
"github.com/optimizely/agent/pkg/metrics"
"github.com/optimizely/agent/pkg/optimizely"
"github.com/optimizely/agent/pkg/routers"
Expand Down Expand Up @@ -267,6 +268,8 @@ func main() {

ctx, cancel := context.WithCancel(context.Background()) // Create default service context
defer cancel()
ctx = context.WithValue(ctx, handlers.LoggerKey, &log.Logger)

sg := server.NewGroup(ctx, conf.Server) // Create a new server group to manage the individual http listeners
optlyCache := optimizely.NewCache(ctx, *conf, sdkMetricsRegistry)
optlyCache.Init(conf.SDKKeys)
Expand Down
4 changes: 3 additions & 1 deletion pkg/handlers/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (h *OptlyWebhookHandler) HandleWebhook(w http.ResponseWriter, r *http.Reque
func (h *OptlyWebhookHandler) StartSyncer(ctx context.Context) error {
logger, ok := ctx.Value(LoggerKey).(*zerolog.Logger)
if !ok {
logger = &zerolog.Logger{}
logger = &log.Logger
}

if !h.syncEnabled {
Expand All @@ -185,8 +185,10 @@ func (h *OptlyWebhookHandler) StartSyncer(ctx context.Context) error {
return
case key := <-dataCh:
h.optlyCache.UpdateConfigs(key)
logger.Debug().Msg("datafile synced successfully")
}
}
}()
logger.Debug().Msg("datafile syncer is started")
return nil
}

0 comments on commit 12773d1

Please sign in to comment.