mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 01:28:27 +08:00
Rename log file based on node id (#8517)
Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com>
This commit is contained in:
parent
d0074c3641
commit
d38adda8c2
@ -12,14 +12,10 @@
|
|||||||
package datacoord
|
package datacoord
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/milvus-io/milvus/internal/log"
|
|
||||||
|
|
||||||
"github.com/milvus-io/milvus/internal/util/paramtable"
|
"github.com/milvus-io/milvus/internal/util/paramtable"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -62,8 +58,6 @@ type ParamTable struct {
|
|||||||
|
|
||||||
CreatedTime time.Time
|
CreatedTime time.Time
|
||||||
UpdatedTime time.Time
|
UpdatedTime time.Time
|
||||||
|
|
||||||
Log log.Config
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var Params ParamTable
|
var Params ParamTable
|
||||||
@ -242,29 +236,7 @@ func (p *ParamTable) initDataCoordSubscriptionName() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *ParamTable) initLogCfg() {
|
func (p *ParamTable) initLogCfg() {
|
||||||
p.Log = log.Config{}
|
p.InitLogCfg("datacoord", 0)
|
||||||
format, err := p.Load("log.format")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
p.Log.Format = format
|
|
||||||
level, err := p.Load("log.level")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
p.Log.Level = level
|
|
||||||
p.Log.File.MaxSize = p.ParseInt("log.file.maxSize")
|
|
||||||
p.Log.File.MaxBackups = p.ParseInt("log.file.maxBackups")
|
|
||||||
p.Log.File.MaxDays = p.ParseInt("log.file.maxAge")
|
|
||||||
rootPath, err := p.Load("log.file.rootPath")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
if len(rootPath) != 0 {
|
|
||||||
p.Log.File.Filename = path.Join(rootPath, "datacoord-"+strconv.FormatInt(p.NodeID, 10)+".log")
|
|
||||||
} else {
|
|
||||||
p.Log.File.Filename = ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ParamTable) initFlushStreamPosSubPath() {
|
func (p *ParamTable) initFlushStreamPosSubPath() {
|
||||||
|
|||||||
@ -157,6 +157,7 @@ func (node *DataNode) Register() error {
|
|||||||
go node.StartWatchChannels(node.ctx)
|
go node.StartWatchChannels(node.ctx)
|
||||||
|
|
||||||
Params.initMsgChannelSubName()
|
Params.initMsgChannelSubName()
|
||||||
|
Params.initLogCfg()
|
||||||
log.Debug("DataNode Init",
|
log.Debug("DataNode Init",
|
||||||
zap.String("MsgChannelSubName", Params.MsgChannelSubName),
|
zap.String("MsgChannelSubName", Params.MsgChannelSubName),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/milvus-io/milvus/internal/log"
|
|
||||||
"github.com/milvus-io/milvus/internal/util/paramtable"
|
"github.com/milvus-io/milvus/internal/util/paramtable"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,7 +34,6 @@ type ParamTable struct {
|
|||||||
FlushInsertBufferSize int64
|
FlushInsertBufferSize int64
|
||||||
InsertBinlogRootPath string
|
InsertBinlogRootPath string
|
||||||
StatsBinlogRootPath string
|
StatsBinlogRootPath string
|
||||||
Log log.Config
|
|
||||||
Alias string // Different datanode in one machine
|
Alias string // Different datanode in one machine
|
||||||
|
|
||||||
// === DataNode External Components Configs ===
|
// === DataNode External Components Configs ===
|
||||||
@ -102,7 +100,6 @@ func (p *ParamTable) Init() {
|
|||||||
p.initFlushInsertBufferSize()
|
p.initFlushInsertBufferSize()
|
||||||
p.initInsertBinlogRootPath()
|
p.initInsertBinlogRootPath()
|
||||||
p.initStatsBinlogRootPath()
|
p.initStatsBinlogRootPath()
|
||||||
p.initLogCfg()
|
|
||||||
|
|
||||||
// === DataNode External Components Configs ===
|
// === DataNode External Components Configs ===
|
||||||
// --- Pulsar ---
|
// --- Pulsar ---
|
||||||
@ -279,27 +276,5 @@ func (p *ParamTable) initMinioBucketName() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *ParamTable) initLogCfg() {
|
func (p *ParamTable) initLogCfg() {
|
||||||
p.Log = log.Config{}
|
p.InitLogCfg("datanode", p.NodeID)
|
||||||
format, err := p.Load("log.format")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
p.Log.Format = format
|
|
||||||
level, err := p.Load("log.level")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
p.Log.Level = level
|
|
||||||
p.Log.File.MaxSize = p.ParseInt("log.file.maxSize")
|
|
||||||
p.Log.File.MaxBackups = p.ParseInt("log.file.maxBackups")
|
|
||||||
p.Log.File.MaxDays = p.ParseInt("log.file.maxAge")
|
|
||||||
rootPath, err := p.Load("log.file.rootPath")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
if len(rootPath) != 0 {
|
|
||||||
p.Log.File.Filename = path.Join(rootPath, "datanode"+p.Alias+".log")
|
|
||||||
} else {
|
|
||||||
p.Log.File.Filename = ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,13 +12,11 @@
|
|||||||
package indexcoord
|
package indexcoord
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/milvus-io/milvus/internal/log"
|
|
||||||
"github.com/milvus-io/milvus/internal/util/paramtable"
|
"github.com/milvus-io/milvus/internal/util/paramtable"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -40,8 +38,6 @@ type ParamTable struct {
|
|||||||
|
|
||||||
CreatedTime time.Time
|
CreatedTime time.Time
|
||||||
UpdatedTime time.Time
|
UpdatedTime time.Time
|
||||||
|
|
||||||
Log log.Config
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var Params ParamTable
|
var Params ParamTable
|
||||||
@ -148,27 +144,5 @@ func (pt *ParamTable) initMinioBucketName() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pt *ParamTable) initLogCfg() {
|
func (pt *ParamTable) initLogCfg() {
|
||||||
pt.Log = log.Config{}
|
pt.InitLogCfg("indexcoord", 0)
|
||||||
format, err := pt.Load("log.format")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
pt.Log.Format = format
|
|
||||||
level, err := pt.Load("log.level")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
pt.Log.Level = level
|
|
||||||
pt.Log.File.MaxSize = pt.ParseInt("log.file.maxSize")
|
|
||||||
pt.Log.File.MaxBackups = pt.ParseInt("log.file.maxBackups")
|
|
||||||
pt.Log.File.MaxDays = pt.ParseInt("log.file.maxAge")
|
|
||||||
rootPath, err := pt.Load("log.file.rootPath")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
if len(rootPath) != 0 {
|
|
||||||
pt.Log.File.Filename = path.Join(rootPath, "indexcoord.log")
|
|
||||||
} else {
|
|
||||||
pt.Log.File.Filename = ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,6 +106,7 @@ func (i *IndexNode) Register() error {
|
|||||||
}
|
}
|
||||||
i.liveCh = i.session.Init(typeutil.IndexNodeRole, Params.IP+":"+strconv.Itoa(Params.Port), false)
|
i.liveCh = i.session.Init(typeutil.IndexNodeRole, Params.IP+":"+strconv.Itoa(Params.Port), false)
|
||||||
Params.NodeID = i.session.ServerID
|
Params.NodeID = i.session.ServerID
|
||||||
|
Params.initLogCfg()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,6 @@
|
|||||||
package indexnode
|
package indexnode
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -53,8 +52,6 @@ type ParamTable struct {
|
|||||||
|
|
||||||
CreatedTime time.Time
|
CreatedTime time.Time
|
||||||
UpdatedTime time.Time
|
UpdatedTime time.Time
|
||||||
|
|
||||||
Log log.Config
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var Params ParamTable
|
var Params ParamTable
|
||||||
@ -76,7 +73,6 @@ func (pt *ParamTable) Init() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
pt.initLogCfg()
|
|
||||||
pt.initParams()
|
pt.initParams()
|
||||||
pt.initKnowhereSimdType()
|
pt.initKnowhereSimdType()
|
||||||
}
|
}
|
||||||
@ -170,29 +166,7 @@ func (pt *ParamTable) initMinioBucketName() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pt *ParamTable) initLogCfg() {
|
func (pt *ParamTable) initLogCfg() {
|
||||||
pt.Log = log.Config{}
|
pt.InitLogCfg("indexnode", pt.NodeID)
|
||||||
format, err := pt.Load("log.format")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
pt.Log.Format = format
|
|
||||||
level, err := pt.Load("log.level")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
pt.Log.Level = level
|
|
||||||
pt.Log.File.MaxSize = pt.ParseInt("log.file.maxSize")
|
|
||||||
pt.Log.File.MaxBackups = pt.ParseInt("log.file.maxBackups")
|
|
||||||
pt.Log.File.MaxDays = pt.ParseInt("log.file.maxAge")
|
|
||||||
rootPath, err := pt.Load("log.file.rootPath")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
if len(rootPath) != 0 {
|
|
||||||
pt.Log.File.Filename = path.Join(rootPath, fmt.Sprintf("indexnode-%s.log", pt.Alias))
|
|
||||||
} else {
|
|
||||||
pt.Log.File.Filename = ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pt *ParamTable) initKnowhereSimdType() {
|
func (pt *ParamTable) initKnowhereSimdType() {
|
||||||
|
|||||||
@ -19,7 +19,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/milvus-io/milvus/internal/log"
|
|
||||||
"github.com/milvus-io/milvus/internal/util/paramtable"
|
"github.com/milvus-io/milvus/internal/util/paramtable"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,7 +36,6 @@ type ParamTable struct {
|
|||||||
|
|
||||||
NetworkAddress string
|
NetworkAddress string
|
||||||
|
|
||||||
// TODO(dragondriver): maybe using the Proxy + ProxyID as the alias is more reasonable
|
|
||||||
Alias string
|
Alias string
|
||||||
|
|
||||||
EtcdEndpoints []string
|
EtcdEndpoints []string
|
||||||
@ -69,7 +67,6 @@ type ParamTable struct {
|
|||||||
MaxTaskNum int64
|
MaxTaskNum int64
|
||||||
|
|
||||||
PulsarMaxMessageSize int
|
PulsarMaxMessageSize int
|
||||||
Log log.Config
|
|
||||||
RoleName string
|
RoleName string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +86,6 @@ func (pt *ParamTable) Init() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.initLogCfg()
|
|
||||||
pt.initEtcdEndpoints()
|
pt.initEtcdEndpoints()
|
||||||
pt.initMetaRootPath()
|
pt.initMetaRootPath()
|
||||||
pt.initPulsarAddress()
|
pt.initPulsarAddress()
|
||||||
@ -277,29 +273,7 @@ func (pt *ParamTable) initPulsarMaxMessageSize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (pt *ParamTable) initLogCfg() {
|
func (pt *ParamTable) initLogCfg() {
|
||||||
pt.Log = log.Config{}
|
pt.InitLogCfg("proxy", pt.ProxyID)
|
||||||
format, err := pt.Load("log.format")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
pt.Log.Format = format
|
|
||||||
level, err := pt.Load("log.level")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
pt.Log.Level = level
|
|
||||||
pt.Log.File.MaxSize = pt.ParseInt("log.file.maxSize")
|
|
||||||
pt.Log.File.MaxBackups = pt.ParseInt("log.file.maxBackups")
|
|
||||||
pt.Log.File.MaxDays = pt.ParseInt("log.file.maxAge")
|
|
||||||
rootPath, err := pt.Load("log.file.rootPath")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
if len(rootPath) != 0 {
|
|
||||||
pt.Log.File.Filename = path.Join(rootPath, fmt.Sprintf("proxy-%s.log", pt.Alias))
|
|
||||||
} else {
|
|
||||||
pt.Log.File.Filename = ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pt *ParamTable) initRoleName() {
|
func (pt *ParamTable) initRoleName() {
|
||||||
|
|||||||
@ -100,6 +100,7 @@ func (node *Proxy) Register() error {
|
|||||||
node.session.Init(typeutil.ProxyRole, Params.NetworkAddress, false)
|
node.session.Init(typeutil.ProxyRole, Params.NetworkAddress, false)
|
||||||
Params.ProxyID = node.session.ServerID
|
Params.ProxyID = node.session.ServerID
|
||||||
Params.initProxySubName()
|
Params.initProxySubName()
|
||||||
|
Params.initLogCfg()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,6 @@ type ParamTable struct {
|
|||||||
// timetick
|
// timetick
|
||||||
TimeTickChannelName string
|
TimeTickChannelName string
|
||||||
|
|
||||||
Log log.Config
|
|
||||||
RoleName string
|
RoleName string
|
||||||
|
|
||||||
// channels
|
// channels
|
||||||
@ -81,7 +80,7 @@ func (p *ParamTable) Init() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
p.initLogCfg()
|
p.BaseTable.InitLogCfg("queryCoord", 0)
|
||||||
|
|
||||||
p.initQueryCoordAddress()
|
p.initQueryCoordAddress()
|
||||||
p.initRoleName()
|
p.initRoleName()
|
||||||
@ -106,32 +105,6 @@ func (p *ParamTable) Init() {
|
|||||||
p.initMinioBucketName()
|
p.initMinioBucketName()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ParamTable) initLogCfg() {
|
|
||||||
p.Log = log.Config{}
|
|
||||||
format, err := p.Load("log.format")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
p.Log.Format = format
|
|
||||||
level, err := p.Load("log.level")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
p.Log.Level = level
|
|
||||||
p.Log.File.MaxSize = p.ParseInt("log.file.maxSize")
|
|
||||||
p.Log.File.MaxBackups = p.ParseInt("log.file.maxBackups")
|
|
||||||
p.Log.File.MaxDays = p.ParseInt("log.file.maxAge")
|
|
||||||
rootPath, err := p.Load("log.file.rootPath")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
if len(rootPath) != 0 {
|
|
||||||
p.Log.File.Filename = path.Join(rootPath, fmt.Sprintf("queryCoord-%d.log", p.NodeID))
|
|
||||||
} else {
|
|
||||||
p.Log.File.Filename = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ParamTable) initQueryCoordAddress() {
|
func (p *ParamTable) initQueryCoordAddress() {
|
||||||
url, err := p.Load("_QueryCoordAddress")
|
url, err := p.Load("_QueryCoordAddress")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -12,8 +12,6 @@
|
|||||||
package querynode
|
package querynode
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"path"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -74,8 +72,6 @@ type ParamTable struct {
|
|||||||
// segcore
|
// segcore
|
||||||
ChunkRows int64
|
ChunkRows int64
|
||||||
SimdType string
|
SimdType string
|
||||||
|
|
||||||
Log log.Config
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var Params ParamTable
|
var Params ParamTable
|
||||||
@ -130,8 +126,6 @@ func (p *ParamTable) Init() {
|
|||||||
|
|
||||||
p.initSegcoreChunkRows()
|
p.initSegcoreChunkRows()
|
||||||
p.initKnowhereSimdType()
|
p.initKnowhereSimdType()
|
||||||
|
|
||||||
p.initLogCfg()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------- minio
|
// ---------------------------------------------------------- minio
|
||||||
@ -298,27 +292,5 @@ func (p *ParamTable) initKnowhereSimdType() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *ParamTable) initLogCfg() {
|
func (p *ParamTable) initLogCfg() {
|
||||||
p.Log = log.Config{}
|
p.InitLogCfg("querynode", p.QueryNodeID)
|
||||||
format, err := p.Load("log.format")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
p.Log.Format = format
|
|
||||||
level, err := p.Load("log.level")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
p.Log.Level = level
|
|
||||||
p.Log.File.MaxSize = p.ParseInt("log.file.maxSize")
|
|
||||||
p.Log.File.MaxBackups = p.ParseInt("log.file.maxBackups")
|
|
||||||
p.Log.File.MaxDays = p.ParseInt("log.file.maxAge")
|
|
||||||
rootPath, err := p.Load("log.file.rootPath")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
if len(rootPath) != 0 {
|
|
||||||
p.Log.File.Filename = path.Join(rootPath, fmt.Sprintf("querynode-%s.log", p.Alias))
|
|
||||||
} else {
|
|
||||||
p.Log.File.Filename = ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,6 +109,7 @@ func (node *QueryNode) Register() error {
|
|||||||
|
|
||||||
// This param needs valid QueryNodeID
|
// This param needs valid QueryNodeID
|
||||||
Params.initMsgChannelSubName()
|
Params.initMsgChannelSubName()
|
||||||
|
Params.initLogCfg()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,12 +12,10 @@
|
|||||||
package rootcoord
|
package rootcoord
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/milvus-io/milvus/internal/log"
|
|
||||||
"github.com/milvus-io/milvus/internal/util/paramtable"
|
"github.com/milvus-io/milvus/internal/util/paramtable"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -55,8 +53,6 @@ type ParamTable struct {
|
|||||||
CreatedTime time.Time
|
CreatedTime time.Time
|
||||||
UpdatedTime time.Time
|
UpdatedTime time.Time
|
||||||
|
|
||||||
Log log.Config
|
|
||||||
|
|
||||||
RoleName string
|
RoleName string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,29 +218,7 @@ func (p *ParamTable) initTimeTickInterval() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *ParamTable) initLogCfg() {
|
func (p *ParamTable) initLogCfg() {
|
||||||
p.Log = log.Config{}
|
p.InitLogCfg("rootcoord", 0)
|
||||||
format, err := p.Load("log.format")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
p.Log.Format = format
|
|
||||||
level, err := p.Load("log.level")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
p.Log.Level = level
|
|
||||||
p.Log.File.MaxSize = p.ParseInt("log.file.maxSize")
|
|
||||||
p.Log.File.MaxBackups = p.ParseInt("log.file.maxBackups")
|
|
||||||
p.Log.File.MaxDays = p.ParseInt("log.file.maxAge")
|
|
||||||
rootPath, err := p.Load("log.file.rootPath")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
if len(rootPath) != 0 {
|
|
||||||
p.Log.File.Filename = path.Join(rootPath, "rootcoord.log")
|
|
||||||
} else {
|
|
||||||
p.Log.File.Filename = ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ParamTable) initRoleName() {
|
func (p *ParamTable) initRoleName() {
|
||||||
|
|||||||
@ -43,6 +43,8 @@ type Base interface {
|
|||||||
type BaseTable struct {
|
type BaseTable struct {
|
||||||
params *memkv.MemoryKV
|
params *memkv.MemoryKV
|
||||||
configDir string
|
configDir string
|
||||||
|
|
||||||
|
Log log.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gp *BaseTable) Init() {
|
func (gp *BaseTable) Init() {
|
||||||
@ -413,3 +415,29 @@ func ConvertRangeToIntSlice(rangeStr, sep string) []int {
|
|||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gp *BaseTable) InitLogCfg(role string, id UniqueID) {
|
||||||
|
gp.Log = log.Config{}
|
||||||
|
format, err := gp.Load("log.format")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
gp.Log.Format = format
|
||||||
|
level, err := gp.Load("log.level")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
gp.Log.Level = level
|
||||||
|
gp.Log.File.MaxSize = gp.ParseInt("log.file.maxSize")
|
||||||
|
gp.Log.File.MaxBackups = gp.ParseInt("log.file.maxBackups")
|
||||||
|
gp.Log.File.MaxDays = gp.ParseInt("log.file.maxAge")
|
||||||
|
rootPath, err := gp.Load("log.file.rootPath")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if len(rootPath) != 0 {
|
||||||
|
gp.Log.File.Filename = path.Join(rootPath, role+"-"+strconv.FormatInt(id, 10)+".log")
|
||||||
|
} else {
|
||||||
|
gp.Log.File.Filename = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -225,3 +225,17 @@ func Test_ConvertRangeToIntSlice(t *testing.T) {
|
|||||||
assert.Panics(t, func() { ConvertRangeToIntSlice("9,0", ",") })
|
assert.Panics(t, func() { ConvertRangeToIntSlice("9,0", ",") })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_InitLogCfg(t *testing.T) {
|
||||||
|
t.Run("TestInitLogCfg", func(t *testing.T) {
|
||||||
|
baseParams.InitLogCfg("rootcoord", 0)
|
||||||
|
assert.Equal(t, baseParams.Log.File.Filename, "")
|
||||||
|
|
||||||
|
baseParams.Save("log.file.rootPath", "/")
|
||||||
|
baseParams.InitLogCfg("rootcoord", 0)
|
||||||
|
assert.Equal(t, baseParams.Log.File.Filename, "/rootcoord-0.log")
|
||||||
|
|
||||||
|
baseParams.InitLogCfg("datanode", 8)
|
||||||
|
assert.Equal(t, baseParams.Log.File.Filename, "/datanode-8.log")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user