File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
3954func load (filePath string ) ([]byte , error ) {
4055 data , err := ioutil .ReadFile (filePath )
4156 return data , err
4257}
4358
4459func 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!!" )
You can’t perform that action at this time.
0 commit comments