[server] Set log level to warn for cli commands

This commit is contained in:
Abhishek Shroff
2025-06-08 23:28:32 +05:30
parent bebd5156f2
commit 7ea0b6819d
2 changed files with 9 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ import (
"codeberg.org/shroff/phylum/server/internal/command/admin"
"codeberg.org/shroff/phylum/server/internal/command/fs"
"codeberg.org/shroff/phylum/server/internal/command/serve"
"codeberg.org/shroff/phylum/server/internal/command/user"
"codeberg.org/shroff/phylum/server/internal/core"
"codeberg.org/shroff/phylum/server/internal/crypt"
"codeberg.org/shroff/phylum/server/internal/db"
@@ -62,6 +63,12 @@ func SetupCommand() {
uuid.EnableRandPool()
cmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
if cmd.Name() == "serve" {
logrus.SetLevel(logrus.InfoLevel)
} else {
logrus.SetLevel(logrus.WarnLevel)
}
dir, _ := cmd.Flags().GetString("workdir")
if dir != "" && dir != "." {
logrus.Info("Changing directory to " + dir)
@@ -124,6 +131,7 @@ func SetupCommand() {
cmd.AddCommand(
admin.SetupCommand(),
fs.SetupCommand(),
user.SetupCommand(),
serve.SetupCommand(),
)
cmd.AddGroup(&cobra.Group{ID: "misc", Title: "Misc"})

View File

@@ -61,7 +61,7 @@ func SetupCommand() *cobra.Command {
err := jobs.Initialize(context.Background(), db.Pool())
if err != nil {
logrus.Fatal("Failed to initializat jobs: " + err.Error())
logrus.Fatal("Failed to initialize jobs: " + err.Error())
}
setupTrashCompactor()