From 332f00ff7a6de6c145f0dabf9b29708ad53bedd4 Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Mon, 24 Jun 2024 14:54:43 +0800 Subject: [PATCH] feat: add cli args -db-log I add a command-line arguments "-db-log" default to false. This help me debug with the gorm SQL. --- cmd/gonic/gonic.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/gonic/gonic.go b/cmd/gonic/gonic.go index 53085c7..fe042e9 100644 --- a/cmd/gonic/gonic.go +++ b/cmd/gonic/gonic.go @@ -68,6 +68,7 @@ func main() { confPlaylistsPath := flag.String("playlists-path", "", "path to your list of new or existing m3u playlists that gonic can manage") confDBPath := flag.String("db-path", "gonic.db", "path to database (optional)") + confDBLog := flag.Bool("db-log", false, "database logging (optional)") confScanIntervalMins := flag.Uint("scan-interval", 0, "interval (in minutes) to automatically scan music (optional)") confScanAtStart := flag.Bool("scan-at-start-enabled", false, "whether to perform an initial scan at startup (optional)") @@ -141,6 +142,7 @@ func main() { if err != nil { log.Fatalf("error opening database: %v\n", err) } + dbc.LogMode(*confDBLog) defer dbc.Close() err = dbc.Migrate(db.MigrationContext{