improved logging

This commit is contained in:
2025-11-20 23:16:16 +01:00
parent 0e47fb6983
commit 239373d5a3
3 changed files with 58 additions and 44 deletions

View File

@@ -1,7 +1,7 @@
package cmd
import (
"log"
"log/slog"
"os"
"path/filepath"
"runtime"
@@ -17,13 +17,18 @@ type args struct {
DeviceID string `arg:"--device-id" default:"steam-immich" help:"Device ID of the uploads"`
Album string `arg:"--album" help:"UUID of a album to upload to"`
CacheFile string `arg:"--cache" default:"$XDG_CACHE_HOME/steam-immich.json" help:"Location of the cache file"`
Revalidate bool `args:"--revalidate" default:"false" help:"Only revalidate and fix the cache"`
Revalidate bool `arg:"--revalidate" help:"Only revalidate and fix the cache"`
Verbose bool `arg:"-v,--verbose" help:"Toggle verbose logging"`
}
func Run() {
var args args
arg.MustParse(&args)
if args.Verbose {
slog.SetLogLoggerLevel(slog.LevelDebug)
}
var steamUserdataDir = ""
if args.UserdataDir != "" {
@@ -33,12 +38,10 @@ func Run() {
}
if steamUserdataDir == "" {
log.Fatal("Can not find steam userdata dir. Please set with --steam-userdata-dir")
slog.Error("Can not find steam userdata dir. Please set with --steam-userdata-dir")
os.Exit(1)
}
// Disable timestamp in log
log.SetFlags(0)
config := steamimmich.Config{
APIKey: args.APIKey,
BaseURL: args.BaseURL,
@@ -49,9 +52,11 @@ func Run() {
}
if args.Revalidate {
steamimmich.Revalidate(config)
statusCode := steamimmich.Revalidate(config)
os.Exit(statusCode)
} else {
steamimmich.Run(config)
statusCode := steamimmich.Run(config)
os.Exit(statusCode)
}
}