mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Merge pull request #530 from oxisto/slog
Added support for structured logging in `csaf_aggregator`
This commit is contained in:
commit
617deb4c17
23 changed files with 135 additions and 91 deletions
|
|
@ -12,13 +12,14 @@ package options
|
|||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
"github.com/csaf-poc/csaf_distribution/v3/util"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/jessevdk/go-flags"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
|
||||
"github.com/csaf-poc/csaf_distribution/v3/util"
|
||||
)
|
||||
|
||||
// Parser helps parsing command line arguments and loading
|
||||
|
|
@ -147,3 +148,13 @@ func ErrorCheck(err error) {
|
|||
log.Fatalf("error: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
// ErrorCheckStructured checks if err is not nil and terminates the program if
|
||||
// so. This is similar to [ErrorCheck], but uses [slog] instead of the
|
||||
// non-structured Go logging.
|
||||
func ErrorCheckStructured(err error) {
|
||||
if err != nil {
|
||||
slog.Error("Error while executing program", "err", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue