summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-06-27 01:56:58 +0100
committerGitHub <noreply@github.com>2021-06-26 20:56:58 -0400
commit35f37a3625476fe5426c35e30e409550054c2d46 (patch)
tree7f69337df87839531a44d1d03ced902dc3754bea /cmd
parent540215588a45464ace455507683b65f1c173ab79 (diff)
downloadgitea-35f37a3625476fe5426c35e30e409550054c2d46.tar.gz
gitea-35f37a3625476fe5426c35e30e409550054c2d46.zip
Add --quiet and --verbose to gitea web to control initial logging (#16260)
One of the repeatedly reported issues has been that gitea produces too much console logging during set up even if the console logger is turned off. Fundamentally this is due to some otherwise very helpful logging that has to occur before logging is set up. This has come to a head with the merging of #16243 where otherwise potentially helpful Trace logging in the git module now appears on the console. This PR proposes three things: 1. Change the initial default logger to Info not Trace. 2. Change the logging for the AppPath things to Info in recompense. 3. Add two new command line options to gitea web: --quiet and --verbose `gitea web -q` or `gitea web --quiet` will only log Fatal level initially. `gitea web -verbose` will log at Trace. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/convert.go8
-rw-r--r--cmd/dump_repo.go10
-rw-r--r--cmd/migrate.go8
-rw-r--r--cmd/migrate_storage.go8
-rw-r--r--cmd/web.go16
5 files changed, 33 insertions, 17 deletions
diff --git a/cmd/convert.go b/cmd/convert.go
index 23a3d8dbe9..e2ffd403ac 100644
--- a/cmd/convert.go
+++ b/cmd/convert.go
@@ -27,10 +27,10 @@ func runConvert(ctx *cli.Context) error {
return err
}
- log.Trace("AppPath: %s", setting.AppPath)
- log.Trace("AppWorkPath: %s", setting.AppWorkPath)
- log.Trace("Custom path: %s", setting.CustomPath)
- log.Trace("Log path: %s", setting.LogRootPath)
+ log.Info("AppPath: %s", setting.AppPath)
+ log.Info("AppWorkPath: %s", setting.AppWorkPath)
+ log.Info("Custom path: %s", setting.CustomPath)
+ log.Info("Log path: %s", setting.LogRootPath)
setting.InitDBConfig()
if !setting.Database.UseMySQL {
diff --git a/cmd/dump_repo.go b/cmd/dump_repo.go
index cea640b534..69813e3c87 100644
--- a/cmd/dump_repo.go
+++ b/cmd/dump_repo.go
@@ -69,7 +69,7 @@ var CmdDumpRepository = cli.Command{
cli.StringFlag{
Name: "units",
Value: "",
- Usage: `Which items will be migrated, one or more units should be separated as comma.
+ Usage: `Which items will be migrated, one or more units should be separated as comma.
wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments are allowed. Empty means all units.`,
},
},
@@ -80,10 +80,10 @@ func runDumpRepository(ctx *cli.Context) error {
return err
}
- log.Trace("AppPath: %s", setting.AppPath)
- log.Trace("AppWorkPath: %s", setting.AppWorkPath)
- log.Trace("Custom path: %s", setting.CustomPath)
- log.Trace("Log path: %s", setting.LogRootPath)
+ log.Info("AppPath: %s", setting.AppPath)
+ log.Info("AppWorkPath: %s", setting.AppWorkPath)
+ log.Info("Custom path: %s", setting.CustomPath)
+ log.Info("Log path: %s", setting.LogRootPath)
setting.InitDBConfig()
var (
diff --git a/cmd/migrate.go b/cmd/migrate.go
index 2428925887..23bc97b0c4 100644
--- a/cmd/migrate.go
+++ b/cmd/migrate.go
@@ -28,10 +28,10 @@ func runMigrate(ctx *cli.Context) error {
return err
}
- log.Trace("AppPath: %s", setting.AppPath)
- log.Trace("AppWorkPath: %s", setting.AppWorkPath)
- log.Trace("Custom path: %s", setting.CustomPath)
- log.Trace("Log path: %s", setting.LogRootPath)
+ log.Info("AppPath: %s", setting.AppPath)
+ log.Info("AppWorkPath: %s", setting.AppWorkPath)
+ log.Info("Custom path: %s", setting.CustomPath)
+ log.Info("Log path: %s", setting.LogRootPath)
setting.InitDBConfig()
if err := models.NewEngine(context.Background(), migrations.Migrate); err != nil {
diff --git a/cmd/migrate_storage.go b/cmd/migrate_storage.go
index 871baed92d..8ff84d690b 100644
--- a/cmd/migrate_storage.go
+++ b/cmd/migrate_storage.go
@@ -110,10 +110,10 @@ func runMigrateStorage(ctx *cli.Context) error {
return err
}
- log.Trace("AppPath: %s", setting.AppPath)
- log.Trace("AppWorkPath: %s", setting.AppWorkPath)
- log.Trace("Custom path: %s", setting.CustomPath)
- log.Trace("Log path: %s", setting.LogRootPath)
+ log.Info("AppPath: %s", setting.AppPath)
+ log.Info("AppWorkPath: %s", setting.AppWorkPath)
+ log.Info("Custom path: %s", setting.CustomPath)
+ log.Info("Log path: %s", setting.LogRootPath)
setting.InitDBConfig()
if err := models.NewEngine(context.Background(), migrations.Migrate); err != nil {
diff --git a/cmd/web.go b/cmd/web.go
index 0ba14ae706..6953e7c64f 100644
--- a/cmd/web.go
+++ b/cmd/web.go
@@ -47,6 +47,14 @@ and it takes care of all the other things for you`,
Value: setting.PIDFile,
Usage: "Custom pid file path",
},
+ cli.BoolFlag{
+ Name: "quiet, q",
+ Usage: "Only display Fatal logging errors until logging is set-up",
+ },
+ cli.BoolFlag{
+ Name: "verbose",
+ Usage: "Set initial logging to TRACE level until logging is properly set-up",
+ },
},
}
@@ -71,6 +79,14 @@ func runHTTPRedirector() {
}
func runWeb(ctx *cli.Context) error {
+ if ctx.Bool("verbose") {
+ _ = log.DelLogger("console")
+ log.NewLogger(0, "console", "console", fmt.Sprintf(`{"level": "trace", "colorize": %t, "stacktraceLevel": "none"}`, log.CanColorStdout))
+ } else if ctx.Bool("quiet") {
+ _ = log.DelLogger("console")
+ log.NewLogger(0, "console", "console", fmt.Sprintf(`{"level": "fatal", "colorize": %t, "stacktraceLevel": "none"}`, log.CanColorStdout))
+ }
+
managerCtx, cancel := context.WithCancel(context.Background())
graceful.InitManager(managerCtx)
defer cancel()