package config import ( "fmt" "log/slog" ) // Prints configuration to stdout in flat dotted format func (conf JobSearchConfig) PrintTerminal() { fmt.Print(conf.String() + "\n") } // Prints configuration to stdout as JSON func (conf JobSearchConfig) PrintJson() { fmt.Print(conf.JSON() + "\n") } // Prints configuration to stdout as YAML func (conf JobSearchConfig) PrintYaml() { fmt.Print(conf.YAML() + "\n") } // Prints configuration to logrus log at debug, info (default) or error level func (conf JobSearchConfig) PrintLog(atLevel slog.Level) { var logFn func(args ...interface{}) switch atLevel { case slog.LevelDebug: logFn = func(args ...interface{}) { slog.Debug(fmt.Sprint(args...)) } case slog.LevelError: logFn = func(args ...interface{}) { slog.Error(fmt.Sprint(args...)) } case slog.LevelWarn: logFn = func(args ...interface{}) { slog.Warn(fmt.Sprint(args...)) } default: logFn = func(args ...interface{}) { slog.Info(fmt.Sprint(args...)) } } for k, v := range conf.Flatten() { logFn("\t", k, " = ", v) } }