You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by ji...@apache.org on 2026/05/07 06:46:32 UTC
(rocketmq-clients) branch master updated: refactor(log.go): unify log configuration default value management (#1239)
This is an automated email from the ASF dual-hosted git repository.
RongtongJin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git
The following commit(s) were added to refs/heads/master by this push:
new 6361fe31 refactor(log.go): unify log configuration default value management (#1239)
6361fe31 is described below
commit 6361fe312161ad32d4f79da48630f30ad7fb2bac
Author: Quan <zs...@foxmail.com>
AuthorDate: Thu May 7 14:46:27 2026 +0800
refactor(log.go): unify log configuration default value management (#1239)
Extract log configuration default values as constants and optimize environment variable reading logic.
---
golang/log.go | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/golang/log.go b/golang/log.go
index a2b3d2bb..d5ef5139 100644
--- a/golang/log.go
+++ b/golang/log.go
@@ -38,6 +38,10 @@ const (
CLIENT_LOG_FILENAME = "rocketmq.client.logFileName"
// CLIENT_LOG_ASYNC_QUEUESIZE = "rocketmq.client.logAsyncQueueSize"
ENABLE_CONSOLE_APPENDER = "mq.consoleAppender.enabled"
+
+ // Default log configuration values
+ defaultLogMaxIndex = 10
+ defaultLogMaxFileSize = 100 // unit: MB
)
var sugarBaseLogger *zap.SugaredLogger
@@ -85,20 +89,20 @@ func getLogWriter() zapcore.WriteSyncer {
homeDir = "/tmp" // fallback to /tmp if home dir cannot be determined
}
clientLogRoot := utils.GetenvWithDef(CLIENT_LOG_ROOT, homeDir+"/logs/rocketmq")
- clientLogMaxIndex := utils.GetenvWithDef(CLIENT_LOG_MAXINDEX, "10")
+ clientLogMaxIndexStr := utils.GetenvWithDef(CLIENT_LOG_MAXINDEX, strconv.Itoa(defaultLogMaxIndex))
clientLogFileName := utils.GetenvWithDef(CLIENT_LOG_FILENAME, "rocketmq_client_go.log")
- clientLogMaxFileSize := utils.GetenvWithDef(CLIENT_LOG_FILESIZE, "100") // unit: MB
+ clientLogMaxFileSizeStr := utils.GetenvWithDef(CLIENT_LOG_FILESIZE, strconv.Itoa(defaultLogMaxFileSize)) // unit: MB
logFileName := clientLogRoot + "/" + clientLogFileName
- maxFileIndex, err := strconv.Atoi(clientLogMaxIndex)
+ maxFileIndex, err := strconv.Atoi(clientLogMaxIndexStr)
if err != nil {
- log.Printf("%s='%s' is invalid and has been replaced with the default value %s", CLIENT_LOG_MAXINDEX, clientLogMaxIndex, "10")
- maxFileIndex = 10
+ log.Printf("%s='%s' is invalid and has been replaced with the default value %d", CLIENT_LOG_MAXINDEX, clientLogMaxIndexStr, defaultLogMaxIndex)
+ maxFileIndex = defaultLogMaxIndex
}
- maxFileSize, err := strconv.Atoi(clientLogMaxFileSize)
+ maxFileSize, err := strconv.Atoi(clientLogMaxFileSizeStr)
if err != nil {
- log.Printf("%s='%s' is invalid and has been replaced with the default value %s", CLIENT_LOG_FILESIZE, clientLogMaxFileSize, "1073741824")
- maxFileSize = 1073741824
+ log.Printf("%s='%s' is invalid and has been replaced with the default value %d", CLIENT_LOG_FILESIZE, clientLogMaxFileSizeStr, defaultLogMaxFileSize)
+ maxFileSize = defaultLogMaxFileSize
}
lumberJackLogger := &lumberjack.Logger{
Filename: logFileName,