mirror of
https://github.com/fhmq/hmq.git
synced 2026-04-22 09:48:33 +00:00
fix(hmq):Set a higher debug level for logs to avoid printing too much log information and interfering with debugging
This commit is contained in:
@@ -31,7 +31,7 @@ type Config struct {
|
||||
WsPort string `json:"wsPort"`
|
||||
WsTLS bool `json:"wsTLS"`
|
||||
TlsInfo TLSInfo `json:"tlsInfo"`
|
||||
Debug bool `json:"debug"`
|
||||
Debug string `json:"debug"`
|
||||
Plugin Plugins `json:"plugins"`
|
||||
UnixFilePath string `json:"unixFilePath"`
|
||||
WindowsPipeName string `json:"windowsPipeName"`
|
||||
@@ -87,12 +87,12 @@ func ConfigureConfig(args []string) (*Config, error) {
|
||||
fs.BoolVar(&help, "help", false, "Show this message.")
|
||||
fs.IntVar(&config.Worker, "w", 1024, "worker num to process message, perfer (client num)/10.")
|
||||
fs.IntVar(&config.Worker, "worker", 1024, "worker num to process message, perfer (client num)/10.")
|
||||
fs.StringVar(&config.HTTPPort, "httpport", "8080", "Port to listen on.")
|
||||
fs.StringVar(&config.HTTPPort, "hp", "8080", "Port to listen on.")
|
||||
fs.StringVar(&config.Port, "port", "", "Port to listen on.")
|
||||
fs.StringVar(&config.Port, "p", "", "Port to listen on.")
|
||||
fs.StringVar(&config.HTTPPort, "httpport", "", "Port to listen on.")
|
||||
fs.StringVar(&config.HTTPPort, "hp", "", "Port to listen on.")
|
||||
fs.StringVar(&config.Port, "port", "8090", "Port to listen on.")
|
||||
fs.StringVar(&config.Port, "p", "8090", "Port to listen on.")
|
||||
fs.StringVar(&config.UnixFilePath, "unixfilepath", "", "unix sock to listen on.")
|
||||
fs.StringVar(&config.Host, "host", "0.0.0.0", "Network host to listen on")
|
||||
fs.StringVar(&config.Host, "host", "127.0.0.1", "Network host to listen on")
|
||||
fs.StringVar(&config.Cluster.Port, "cp", "", "Cluster port from which members can connect.")
|
||||
fs.StringVar(&config.Cluster.Port, "clusterport", "", "Cluster port from which members can connect.")
|
||||
fs.StringVar(&config.Router, "r", "", "Router who maintenance cluster info")
|
||||
@@ -103,8 +103,8 @@ func ConfigureConfig(args []string) (*Config, error) {
|
||||
fs.StringVar(&config.WsPath, "wspath", "", "path for ws to listen on")
|
||||
fs.StringVar(&configFile, "config", "", "config file for hmq")
|
||||
fs.StringVar(&configFile, "c", "", "config file for hmq")
|
||||
fs.BoolVar(&config.Debug, "debug", false, "enable Debug logging.")
|
||||
fs.BoolVar(&config.Debug, "d", false, "enable Debug logging.")
|
||||
fs.StringVar(&config.Debug, "debug", "info", "enable Debug logging.")
|
||||
fs.StringVar(&config.Debug, "d", "info", "enable Debug logging.")
|
||||
|
||||
fs.Bool("D", true, "enable Debug logging.")
|
||||
|
||||
@@ -120,7 +120,7 @@ func ConfigureConfig(args []string) (*Config, error) {
|
||||
fs.Visit(func(f *flag.Flag) {
|
||||
switch f.Name {
|
||||
case "D":
|
||||
config.Debug = true
|
||||
config.Debug = "debug"
|
||||
}
|
||||
})
|
||||
|
||||
@@ -133,7 +133,15 @@ func ConfigureConfig(args []string) (*Config, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if config.Debug {
|
||||
//Set the debug level of logs
|
||||
switch config.Debug {
|
||||
case "debug":
|
||||
log = logger.Debug().Named("broker")
|
||||
case "info":
|
||||
log = logger.Prod().Named("broker")
|
||||
case "release":
|
||||
log = logger.Release().Named("broker")
|
||||
default:
|
||||
log = logger.Debug().Named("broker")
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,15 @@ func NewProdLogger() (*zap.Logger, error) {
|
||||
return logCfg.Build()
|
||||
}
|
||||
|
||||
// NewReleaseLogger return a logger for production builds
|
||||
func NewReleaseLogger() (*zap.Logger, error) {
|
||||
logCfg := zap.NewProductionConfig()
|
||||
logCfg.DisableStacktrace = true
|
||||
logCfg.Level = zap.NewAtomicLevelAt(zap.ErrorLevel)
|
||||
logCfg.EncoderConfig = encoderCfg
|
||||
return logCfg.Build()
|
||||
}
|
||||
|
||||
func Prod() *zap.Logger {
|
||||
|
||||
l, _ := NewProdLogger()
|
||||
@@ -54,6 +63,14 @@ func Debug() *zap.Logger {
|
||||
return instance
|
||||
}
|
||||
|
||||
func Release() *zap.Logger {
|
||||
|
||||
l, _ := NewReleaseLogger()
|
||||
instance = l
|
||||
|
||||
return instance
|
||||
}
|
||||
|
||||
func Get() *zap.Logger {
|
||||
if instance == nil {
|
||||
l, _ := NewProdLogger()
|
||||
|
||||
Reference in New Issue
Block a user