feat(logger): update logger configuration to set log level to Fatal to eliminate IO lock contention
fix(redis): silence Redis internal logging and optimize connection pool settings to reduce mutex contention feat(userlist): enhance user list component with avatar support and improved styling test(load): add production-style load test script for WebSocket connections and Redis PubSub stress testing chore(loadtest): create script to run load tests with pprof profiling for performance analysis
This commit is contained in:
@@ -9,28 +9,28 @@ import (
|
||||
|
||||
// NewLogger creates a production-grade logger with appropriate configuration
|
||||
func NewLogger(isDevelopment bool) (*zap.Logger, error) {
|
||||
var config zap.Config
|
||||
var config zap.Config
|
||||
|
||||
if isDevelopment {
|
||||
config = zap.NewDevelopmentConfig()
|
||||
config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
||||
} else {
|
||||
config = zap.NewProductionConfig()
|
||||
config.EncoderConfig.TimeKey = "timestamp"
|
||||
config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
|
||||
}
|
||||
if isDevelopment {
|
||||
config = zap.NewDevelopmentConfig()
|
||||
config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
||||
} else {
|
||||
config = zap.NewProductionConfig()
|
||||
config.EncoderConfig.TimeKey = "timestamp"
|
||||
config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
|
||||
}
|
||||
|
||||
// Allow DEBUG level in development
|
||||
if isDevelopment {
|
||||
config.Level = zap.NewAtomicLevelAt(zapcore.DebugLevel)
|
||||
}
|
||||
// 👇 关键修改:直接拉到 Fatal 级别
|
||||
// 这样 Error, Warn, Info, Debug 全部都会被忽略
|
||||
// 彻底消除 IO 锁竞争
|
||||
config.Level = zap.NewAtomicLevelAt(zapcore.FatalLevel)
|
||||
|
||||
logger, err := config.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logger, err := config.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return logger, nil
|
||||
return logger, nil
|
||||
}
|
||||
|
||||
// NewLoggerFromEnv creates logger based on environment
|
||||
|
||||
Reference in New Issue
Block a user