[internal/logging] add logging lib

This commit is contained in:
2023-11-03 14:32:27 +01:00
parent 7256763c20
commit 2a530681df
21 changed files with 148 additions and 61 deletions

View File

@@ -37,7 +37,7 @@ func writeToFile(path string, documenter internal.Documenter) error {
f, err := os.Create(fileName)
if err != nil {
fmt.Println(err)
internal.Log.Errorf("Error during writeToFile: %s", err)
return err
}
@@ -46,7 +46,7 @@ func writeToFile(path string, documenter internal.Documenter) error {
_, err = f.WriteString(getMarkdown(documenter))
if err != nil {
fmt.Println(err)
internal.Log.Errorf("Error during writeToFile: %s", err)
return err
}
@@ -86,9 +86,12 @@ func printDocumentersSummary() {
func main() {
outputPath := flag.String("output", "", "path where docs/ shoud be created")
verbose := flag.Bool("verbose", false, "log debug information")
flag.Parse()
internal.InitLogger()
internal.SetVerbose(*verbose)
if *outputPath == "" {
printDocumentersSummary()
return

View File

@@ -37,19 +37,24 @@ func GetDocumentation() string {
}
func main() {
configFilePath := flag.String("c", "", "path to config file")
showDoc := flag.Bool("d", false, "show doc")
testRun := flag.Bool("t", false, "test run")
verbose := flag.Bool("verbose", false, "log debug info")
flag.Parse()
internal.InitLogger()
internal.SetVerbose(*verbose)
if *showDoc {
fmt.Print(GetDocumentation())
return
}
if *configFilePath == "" {
fmt.Println("No config file given. Use --help to show usage.")
internal.Log.Warning("No config file given. Use --help to show usage.")
return
}
@@ -58,7 +63,7 @@ func main() {
configFile, err := os.ReadFile(*configFilePath)
if err != nil {
fmt.Println("Error loading config file: ", err)
internal.Log.Errorf("Error loading config file: %s", err)
return
}
@@ -66,7 +71,7 @@ func main() {
err = json.Unmarshal(configFile, &f)
if err != nil {
fmt.Println(err)
internal.Log.Errorf("Error pasing json file: %s", err)
return
}
@@ -75,7 +80,7 @@ func main() {
trigger, err := triggers.NewTrigger(cfg)
if err != nil {
fmt.Println(err)
internal.Log.Errorf("%s", err)
return
}