Skip to content

Commit ea45360

Browse files
committed
Add default configurations when unset /home/ubuntu/cb-spider
1 parent e189d2f commit ea45360

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

config.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,34 @@ type CBLOGCONFIG struct {
3636
}
3737
}
3838

39+
func NewCBLOGCONFIG() CBLOGCONFIG {
40+
config := CBLOGCONFIG{}
41+
42+
config.CBLOG.LOOPCHECK = false
43+
config.CBLOG.LOGLEVEL = "info"
44+
config.CBLOG.LOGFILE = true
45+
46+
config.LOGFILEINFO.FILENAME = "logfile.log"
47+
config.LOGFILEINFO.MAXSIZE = 10 // in MB
48+
config.LOGFILEINFO.MAXBACKUPS = 5
49+
config.LOGFILEINFO.MAXAGE = 31 // in days
50+
51+
return config
52+
}
53+
3954
func load(filePath string) ([]byte, error) {
4055
data, err := ioutil.ReadFile(filePath)
4156
return data, err
4257
}
4358

4459
func GetConfigInfos(configFilePath string) CBLOGCONFIG {
4560
var filePath string
61+
4662
cblogRootPath := os.Getenv("CBLOG_ROOT")
63+
if cblogRootPath == "" {
64+
log.Printf("CBLOG_ROOT is not set. Using default configurations")
65+
return NewCBLOGCONFIG()
66+
}
4767

4868
if cblogRootPath == "" && configFilePath == "" {
4969
log.Fatalf("Both $CBLOG_ROOT and configPath are not set!!")

0 commit comments

Comments
 (0)