Skip to content

Commit

Permalink
add logger to manager events handler
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Okhlopkov <[email protected]>
  • Loading branch information
Pavel Okhlopkov committed Oct 21, 2024
1 parent 8020163 commit 2137ba5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 0 additions & 2 deletions pkg/app/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,13 @@ func SetupLogging(runtimeConfig *config.Config, logger *unilogger.Logger) {
// log.SetFormatter(&ProxyJsonWrapperFormatter{WrappedFormatter: formatter})
// }

logger.SetLevel(unilogger.LogLevelFromStr(LogLevel))
unilogger.SetDefaultLevel(unilogger.LogLevelFromStr(LogLevel))

runtimeConfig.Register("log.level",
fmt.Sprintf("Global log level. Default duration for debug level is %s", ForcedDurationForDebugLevel),
strings.ToLower(LogLevel),
func(oldValue string, newValue string) error {
log.Infof("Set log level to '%s'", newValue)
logger.SetLevel(unilogger.LogLevelFromStr(newValue))
unilogger.SetDefaultLevel(unilogger.LogLevelFromStr(LogLevel))
return nil
}, func(oldValue string, newValue string) time.Duration {
Expand Down
7 changes: 4 additions & 3 deletions pkg/shell-operator/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,10 @@ func (op *ShellOperator) SetupEventManagers() {

// Initialize events handler that emit tasks to run hooks
cfg := &managerEventsHandlerConfig{
tqs: op.TaskQueues,
mgr: op.KubeEventsManager,
smgr: op.ScheduleManager,
tqs: op.TaskQueues,
mgr: op.KubeEventsManager,
smgr: op.ScheduleManager,
logger: op.logger.Named("manager-events-handler"),
}
op.ManagerEventsHandler = newManagerEventsHandler(op.ctx, cfg)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/shell-operator/manager_events_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type managerEventsHandlerConfig struct {
mgr kube_events_manager.KubeEventsManager
smgr schedule_manager.ScheduleManager

Logger *unilogger.Logger
logger *unilogger.Logger
}

type ManagerEventsHandler struct {
Expand Down Expand Up @@ -48,7 +48,7 @@ func newManagerEventsHandler(ctx context.Context, cfg *managerEventsHandlerConfi
scheduleManager: cfg.smgr,
kubeEventsManager: cfg.mgr,
taskQueues: cfg.tqs,
logger: cfg.Logger,
logger: cfg.logger,
}
}

Expand Down

0 comments on commit 2137ba5

Please sign in to comment.