improved logging for debug
This commit is contained in:
@@ -21,6 +21,7 @@ var (
|
||||
// remove/change default
|
||||
platform = pflag.StringP("platform", "p", "trading212", "One of the supported platforms")
|
||||
lang = pflag.StringP("language", "l", language.Portuguese.String(), "The 2 letter language code")
|
||||
debug = pflag.BoolP("debug", "d", false, "Activate to log debug messages")
|
||||
ofAPIKey = pflag.String("open-figi-api-key", "", "An OpenFIGI API key for faster report generation (better rate api rate limits)")
|
||||
// TODO: improve documentation on selectors
|
||||
selectors = pflag.StringSlice("selectors", nil, "Only process entries that conform to all the selectors:")
|
||||
@@ -42,7 +43,11 @@ func run(ctx context.Context) error {
|
||||
|
||||
eg, ctx := errgroup.WithContext(ctx)
|
||||
|
||||
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, nil)))
|
||||
logLevel := slog.LevelInfo
|
||||
if *debug {
|
||||
logLevel = slog.LevelDebug
|
||||
}
|
||||
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: logLevel})))
|
||||
|
||||
if platform == nil || len(*platform) == 0 {
|
||||
slog.Error("--platform flag is required")
|
||||
|
||||
Reference in New Issue
Block a user