Add proper logging
This commit is contained in:
@@ -27,7 +27,7 @@ func LoadZurgConfig(filename string) (ConfigInterface, error) {
|
||||
rlog := logutil.NewLogger()
|
||||
log := rlog.Named("config")
|
||||
|
||||
log.Debug("Loading config file", filename)
|
||||
log.Debug("Loading config file ", filename)
|
||||
content, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -10,14 +10,10 @@ import (
|
||||
)
|
||||
|
||||
func loadV1Config(content []byte) (*ZurgConfigV1, error) {
|
||||
rlog := logutil.NewLogger()
|
||||
log := rlog.Named("config")
|
||||
|
||||
var configV1 ZurgConfigV1
|
||||
if err := yaml.Unmarshal(content, &configV1); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Debug("V1 config loaded successfully")
|
||||
|
||||
return &configV1, nil
|
||||
}
|
||||
@@ -27,13 +23,9 @@ func (z *ZurgConfigV1) GetVersion() string {
|
||||
}
|
||||
|
||||
func (z *ZurgConfigV1) GetDirectories() []string {
|
||||
rlog := logutil.NewLogger()
|
||||
log := rlog.Named("config")
|
||||
|
||||
rootDirectories := make([]string, len(z.Directories))
|
||||
i := 0
|
||||
for directory := range z.Directories {
|
||||
log.Debug("Adding to rootDirectories", directory)
|
||||
rootDirectories[i] = directory
|
||||
i++
|
||||
}
|
||||
@@ -41,12 +33,9 @@ func (z *ZurgConfigV1) GetDirectories() []string {
|
||||
}
|
||||
|
||||
func (z *ZurgConfigV1) GetGroupMap() map[string][]string {
|
||||
// Obtain a new sugared logger instance
|
||||
rlog := logutil.NewLogger()
|
||||
log := rlog.Named("config")
|
||||
|
||||
log.Debug("Starting to build the group map from directories")
|
||||
|
||||
var groupMap = make(map[string][]string)
|
||||
var groupOrderMap = make(map[string]int) // To store GroupOrder for each directory
|
||||
|
||||
@@ -54,7 +43,7 @@ func (z *ZurgConfigV1) GetGroupMap() map[string][]string {
|
||||
for directory, val := range z.Directories {
|
||||
groupMap[val.Group] = append(groupMap[val.Group], directory)
|
||||
groupOrderMap[directory] = val.GroupOrder
|
||||
log.Debugf("Added directory to group: %s, group: %s, groupOrder: %d", directory, val.Group, val.GroupOrder)
|
||||
log.Debugf("Added directory to group: %s, group: %s, order: %d", directory, val.Group, val.GroupOrder)
|
||||
}
|
||||
|
||||
// Sort the slice based on GroupOrder and then directory name for deterministic order
|
||||
@@ -66,7 +55,7 @@ func (z *ZurgConfigV1) GetGroupMap() map[string][]string {
|
||||
return groupOrderMap[dirs[i]] < groupOrderMap[dirs[j]]
|
||||
})
|
||||
groupMap[group] = dirs
|
||||
log.Debugf("Sorted directories within a group: %s, sortedDirectories: %v", group, dirs)
|
||||
log.Debugf("Sorted directories within a group: %s %v", group, dirs)
|
||||
}
|
||||
|
||||
// Return a deep copy of the map
|
||||
|
||||
Reference in New Issue
Block a user