mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-07 04:12:55 +02:00
add debug mode and update readme
This commit is contained in:
40
modules/debug/debug.go
Normal file
40
modules/debug/debug.go
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package debug
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
var debug bool
|
||||
|
||||
func IsDebug() bool {
|
||||
return debug
|
||||
}
|
||||
|
||||
func SetDebug(on bool) {
|
||||
debug = on
|
||||
}
|
||||
|
||||
func Printf(info string, args ...any) {
|
||||
if debug {
|
||||
fmt.Printf("DEBUG: "+info+"\n", args...)
|
||||
}
|
||||
}
|
||||
|
||||
func CliFlag() cli.Flag {
|
||||
return &cli.BoolFlag{
|
||||
Name: "debug",
|
||||
Aliases: []string{"vvv"},
|
||||
Usage: "Enable debug mode",
|
||||
Value: false,
|
||||
Action: func(ctx context.Context, cmd *cli.Command, v bool) error {
|
||||
SetDebug(v)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user