diff options
Diffstat (limited to 'cmd/manager_logging.go')
-rw-r--r-- | cmd/manager_logging.go | 155 |
1 files changed, 94 insertions, 61 deletions
diff --git a/cmd/manager_logging.go b/cmd/manager_logging.go index 70d1beb26d..84c962561e 100644 --- a/cmd/manager_logging.go +++ b/cmd/manager_logging.go @@ -10,49 +10,61 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/private" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) var ( defaultLoggingFlags = []cli.Flag{ - cli.StringFlag{ + &cli.StringFlag{ Name: "logger", Usage: `Logger name - will default to "default"`, - }, cli.StringFlag{ + }, + &cli.StringFlag{ Name: "writer", Usage: "Name of the log writer - will default to mode", - }, cli.StringFlag{ + }, + &cli.StringFlag{ Name: "level", Usage: "Logging level for the new logger", - }, cli.StringFlag{ - Name: "stacktrace-level, L", - Usage: "Stacktrace logging level", - }, cli.StringFlag{ - Name: "flags, F", - Usage: "Flags for the logger", - }, cli.StringFlag{ - Name: "expression, e", - Usage: "Matching expression for the logger", - }, cli.StringFlag{ - Name: "prefix, p", - Usage: "Prefix for the logger", - }, cli.BoolFlag{ + }, + &cli.StringFlag{ + Name: "stacktrace-level", + Aliases: []string{"L"}, + Usage: "Stacktrace logging level", + }, + &cli.StringFlag{ + Name: "flags", + Aliases: []string{"F"}, + Usage: "Flags for the logger", + }, + &cli.StringFlag{ + Name: "expression", + Aliases: []string{"e"}, + Usage: "Matching expression for the logger", + }, + &cli.StringFlag{ + Name: "prefix", + Aliases: []string{"p"}, + Usage: "Prefix for the logger", + }, + &cli.BoolFlag{ Name: "color", Usage: "Use color in the logs", - }, cli.BoolFlag{ + }, + &cli.BoolFlag{ Name: "debug", }, } - subcmdLogging = cli.Command{ + subcmdLogging = &cli.Command{ Name: "logging", Usage: "Adjust logging commands", - Subcommands: []cli.Command{ + Subcommands: []*cli.Command{ { Name: "pause", Usage: "Pause logging (Gitea will buffer logs up to a certain point and will drop them after that point)", Flags: []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: "debug", }, }, @@ -61,7 +73,7 @@ var ( Name: "resume", Usage: "Resume logging", Flags: []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: "debug", }, }, @@ -70,7 +82,7 @@ var ( Name: "release-and-reopen", Usage: "Cause Gitea to release and re-open files used for logging", Flags: []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: "debug", }, }, @@ -80,9 +92,9 @@ var ( Usage: "Remove a logger", ArgsUsage: "[name] Name of logger to remove", Flags: []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: "debug", - }, cli.StringFlag{ + }, &cli.StringFlag{ Name: "logger", Usage: `Logger name - will default to "default"`, }, @@ -91,32 +103,45 @@ var ( }, { Name: "add", Usage: "Add a logger", - Subcommands: []cli.Command{ + Subcommands: []*cli.Command{ { Name: "file", Usage: "Add a file logger", Flags: append(defaultLoggingFlags, []cli.Flag{ - cli.StringFlag{ - Name: "filename, f", - Usage: "Filename for the logger - this must be set.", - }, cli.BoolTFlag{ - Name: "rotate, r", - Usage: "Rotate logs", - }, cli.Int64Flag{ - Name: "max-size, s", - Usage: "Maximum size in bytes before rotation", - }, cli.BoolTFlag{ - Name: "daily, d", - Usage: "Rotate logs daily", - }, cli.IntFlag{ - Name: "max-days, D", - Usage: "Maximum number of daily logs to keep", - }, cli.BoolTFlag{ - Name: "compress, z", - Usage: "Compress rotated logs", - }, cli.IntFlag{ - Name: "compression-level, Z", - Usage: "Compression level to use", + &cli.StringFlag{ + Name: "filename", + Aliases: []string{"f"}, + Usage: "Filename for the logger - this must be set.", + }, + &cli.BoolFlag{ + Name: "rotate", + Aliases: []string{"r"}, + Usage: "Rotate logs", + }, + &cli.Int64Flag{ + Name: "max-size", + Aliases: []string{"s"}, + Usage: "Maximum size in bytes before rotation", + }, + &cli.BoolFlag{ + Name: "daily", + Aliases: []string{"d"}, + Usage: "Rotate logs daily", + }, + &cli.IntFlag{ + Name: "max-days", + Aliases: []string{"D"}, + Usage: "Maximum number of daily logs to keep", + }, + &cli.BoolFlag{ + Name: "compress", + Aliases: []string{"z"}, + Usage: "Compress rotated logs", + }, + &cli.IntFlag{ + Name: "compression-level", + Aliases: []string{"Z"}, + Usage: "Compression level to use", }, }...), Action: runAddFileLogger, @@ -124,18 +149,25 @@ var ( Name: "conn", Usage: "Add a net conn logger", Flags: append(defaultLoggingFlags, []cli.Flag{ - cli.BoolFlag{ - Name: "reconnect-on-message, R", - Usage: "Reconnect to host for every message", - }, cli.BoolFlag{ - Name: "reconnect, r", - Usage: "Reconnect to host when connection is dropped", - }, cli.StringFlag{ - Name: "protocol, P", - Usage: "Set protocol to use: tcp, unix, or udp (defaults to tcp)", - }, cli.StringFlag{ - Name: "address, a", - Usage: "Host address and port to connect to (defaults to :7020)", + &cli.BoolFlag{ + Name: "reconnect-on-message", + Aliases: []string{"R"}, + Usage: "Reconnect to host for every message", + }, + &cli.BoolFlag{ + Name: "reconnect", + Aliases: []string{"r"}, + Usage: "Reconnect to host when connection is dropped", + }, + &cli.StringFlag{ + Name: "protocol", + Aliases: []string{"P"}, + Usage: "Set protocol to use: tcp, unix, or udp (defaults to tcp)", + }, + &cli.StringFlag{ + Name: "address", + Aliases: []string{"a"}, + Usage: "Host address and port to connect to (defaults to :7020)", }, }...), Action: runAddConnLogger, @@ -145,9 +177,10 @@ var ( Name: "log-sql", Usage: "Set LogSQL", Flags: []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: "debug", - }, cli.BoolFlag{ + }, + &cli.BoolFlag{ Name: "off", Usage: "Switch off SQL logging", }, |