Skip to content

Commit

Permalink
change logging verbosity (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbauriedel authored Dec 19, 2023
1 parent 0083bb4 commit fe33988
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,16 @@ func main() {
for _, name := range moduleOrder {
switch {
case util.StringInSlice(name, disabledModules):
c.Log.Infof("Module %s is disabled", name)
c.Log.Debugf("Module %s is disabled", name)
case !util.StringInSlice(name, enabledModules):
c.Log.Infof("Module %s is not enabled", name)
c.Log.Debugf("Module %s is not enabled", name)
default:
moduleStart := time.Now()

c.Log.Debugf("Calling module %s", name)
c.Log.Debugf("Start collecting data for module %s", name)

for _, o := range extraObfuscators {
c.Log.Debugf("Adding obfuscator for '%s' to module %s", o, name)
c.Log.Debugf("Adding custom obfuscator for '%s' to module %s", o, name)
c.RegisterObfuscator(obfuscate.NewAny(o))
}

Expand Down
4 changes: 2 additions & 2 deletions modules/graphite/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func Collect(c *collection.Collection) {
}

if !pythonFound {
c.Log.Warn("Python not found on system")
c.Log.Debug("Python not found on system")
}

for _, file := range files {
Expand All @@ -101,7 +101,7 @@ func Collect(c *collection.Collection) {

processList, err := collection.ProcessListFilter(processFilter)
if err != nil {
c.Log.Warn("cant get process list")
c.Log.Debug("cant get process list")
}

// save process names to string array
Expand Down
2 changes: 1 addition & 1 deletion modules/icinga2/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func Collect(c *collection.Collection) {

content, err := collection.LoadCommandOutput("icinga2", "-V")
if err != nil {
c.Log.Info("Could not find icinga2")
c.Log.Debug("Could not find executable for icinga2")

icinga2version = ""
} else {
Expand Down
4 changes: 2 additions & 2 deletions modules/icingaweb2/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ func Collect(c *collection.Collection) {

func CollectModuleInfo(c *collection.Collection) {
if !collection.DetectGitInstalled() {
c.Log.Warnf("we need git to inspect modules closer")
c.Log.Debug("we need git to inspect modules closer")
}

modulesFiles, err := os.ReadDir(ModulesPath)
if err != nil {
c.Log.Warnf("Could not list modules in %s - %s", ModulesPath, err)
c.Log.Debugf("Could not list modules in %s - %s", ModulesPath, err)
return
}

Expand Down
14 changes: 7 additions & 7 deletions pkg/collection/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (c *Collection) AddFileYAML(fileName string, data interface{}) {

err := yaml.NewEncoder(&buf).Encode(&data)
if err != nil {
c.Log.Warnf("could not encode YAML data for '%s': %s", fileName, err)
c.Log.Debugf("could not encode YAML data for '%s': %s", fileName, err)
}

file := NewFile(fileName)
Expand All @@ -145,7 +145,7 @@ func (c *Collection) AddFiles(prefix, source string) {

files, err := LoadFiles(prefix, source)
if err != nil {
c.Log.Warn(err)
c.Log.Debug(err)
}

for _, file := range files {
Expand Down Expand Up @@ -182,13 +182,13 @@ func (c *Collection) AddCommandOutputWithTimeout(file string,

output, err := LoadCommandOutputWithTimeout(timeout, command, arguments...)
if err != nil {
c.Log.Warn(err)
c.Log.Debug(err)
}

// obfuscate
output, err = c.callObfuscators(obfuscate.KindOutput, obfuscate.JoinCommand(command, arguments...), output)
if err != nil {
c.Log.Warn(err)
c.Log.Debug(err)
}

c.AddFileDataRaw(file, output)
Expand All @@ -203,7 +203,7 @@ func (c *Collection) AddInstalledPackagesRaw(fileName string, pattern ...string)

packages, err := ListInstalledPackagesRaw(pattern...)
if err != nil {
c.Log.Warn(err)
c.Log.Debug(err)
}

c.AddFileDataRaw(fileName, packages)
Expand All @@ -214,7 +214,7 @@ func (c *Collection) AddServiceStatusRaw(fileName, name string) {

output, err := GetServiceStatusRaw(name)
if err != nil {
c.Log.Warn(err)
c.Log.Debug(err)
}

c.AddFileDataRaw(fileName, output)
Expand All @@ -225,7 +225,7 @@ func (c *Collection) AddGitRepoInfo(fileName, path string) {

info, err := LoadGitRepoInfo(path)
if err != nil {
c.Log.Warn(err)
c.Log.Debug(err)
}

c.AddFileYAML(fileName, info)
Expand Down

0 comments on commit fe33988

Please sign in to comment.