diff options
author | zeripath <art27@cantab.net> | 2022-06-24 11:49:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-24 12:49:47 +0200 |
commit | 4909493a9f75ad188f044b8577e7357f122fb445 (patch) | |
tree | 56d3c97df67b0a0846bbb9a92ebd4fb1e90ab4e4 /cmd | |
parent | afea63f4e5a4b7e3da03a7d5fc6590569976e7d3 (diff) | |
download | gitea-4909493a9f75ad188f044b8577e7357f122fb445.tar.gz gitea-4909493a9f75ad188f044b8577e7357f122fb445.zip |
Allow manager logging to set SQL (#20064)
This PR adds a new manager command to switch on SQL logging and to turn it off.
```
gitea manager logging log-sql
gitea manager logging log-sql --off
```
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/manager_logging.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cmd/manager_logging.go b/cmd/manager_logging.go index 0043ea1e52..761edf654c 100644 --- a/cmd/manager_logging.go +++ b/cmd/manager_logging.go @@ -174,6 +174,18 @@ var ( Action: runAddSMTPLogger, }, }, + }, { + Name: "log-sql", + Usage: "Set LogSQL", + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "debug", + }, cli.BoolFlag{ + Name: "off", + Usage: "Switch off SQL logging", + }, + }, + Action: runSetLogSQL, }, }, } @@ -381,3 +393,18 @@ func runReleaseReopenLogging(c *cli.Context) error { fmt.Fprintln(os.Stdout, msg) return nil } + +func runSetLogSQL(c *cli.Context) error { + ctx, cancel := installSignals() + defer cancel() + setup("manager", c.Bool("debug")) + + statusCode, msg := private.SetLogSQL(ctx, !c.Bool("off")) + switch statusCode { + case http.StatusInternalServerError: + return fail("InternalServerError", msg) + } + + fmt.Fprintln(os.Stdout, msg) + return nil +} |