Skip to content

Commit

Permalink
main: make sure the Welcome TiProxy info is always printed. (#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
yorkhellen authored Apr 13, 2024
1 parent c51070d commit f427940
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/manager/logger/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func (lm *LoggerManager) Init(cfgch <-chan *config.Config) {
}, nil, lm.logger)
}

func (lm *LoggerManager) SetLoggerLevel(l zapcore.Level) {
lm.level.SetLevel(l)
}

func (lm *LoggerManager) watchCfg(ctx context.Context, cfgch <-chan *config.Config) {
for {
select {
Expand Down
4 changes: 4 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ func NewServer(ctx context.Context, sctx *sctx.Context) (srv *Server, err error)
//
// TODO: there is a race condition that printInfo and logmgr may concurrently execute:
// logmgr may havenot been initialized with logfile yet
// Make sure the TiProxy info is always printed.
level := lg.Level()
srv.LoggerManager.SetLoggerLevel(zap.InfoLevel)
printInfo(lg)
srv.LoggerManager.SetLoggerLevel(level)

// setup metrics
srv.MetricsManager.Init(ctx, lg.Named("metrics"))
Expand Down

0 comments on commit f427940

Please sign in to comment.