From f427940026d51e03c8f0720a5075a1fabdb82fbe Mon Sep 17 00:00:00 2001 From: "zhangxiaoyu.york" <516302150@qq.com> Date: Sat, 13 Apr 2024 12:02:36 +0800 Subject: [PATCH] main: make sure the Welcome TiProxy info is always printed. (#507) --- pkg/manager/logger/manager.go | 4 ++++ pkg/server/server.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/pkg/manager/logger/manager.go b/pkg/manager/logger/manager.go index d013bb28..0b38e6fa 100644 --- a/pkg/manager/logger/manager.go +++ b/pkg/manager/logger/manager.go @@ -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 { diff --git a/pkg/server/server.go b/pkg/server/server.go index e5761d7b..faf9716d 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -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"))