mirror of
https://github.com/netfun2000/rttys_zhaojh329.git
synced 2026-02-27 09:53:24 +08:00
feat: it's configurable whether log caller
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
+5
-1
@@ -52,7 +52,7 @@ func init() {
|
||||
}
|
||||
|
||||
out := consoleEx.ConsoleWriterEx{Out: colorable.NewColorableStdout()}
|
||||
logger := zerolog.New(out).With().Caller().Timestamp().Logger()
|
||||
logger := zerolog.New(out).With().Timestamp().Logger()
|
||||
|
||||
if !terminal.IsTerminal(int(os.Stdout.Fd())) {
|
||||
logger = logger.Hook(logFile)
|
||||
@@ -65,3 +65,7 @@ func init() {
|
||||
func SetPath(path string) {
|
||||
logFile.path = path
|
||||
}
|
||||
|
||||
func Verbose() {
|
||||
log.Logger = log.Logger.With().Caller().Logger()
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"runtime"
|
||||
|
||||
"rttys/config"
|
||||
rlog "rttys/log"
|
||||
xlog "rttys/log"
|
||||
"rttys/utils"
|
||||
"rttys/version"
|
||||
|
||||
@@ -40,7 +40,11 @@ func initDb(cfg *config.Config) error {
|
||||
}
|
||||
|
||||
func runRttys(c *cli.Context) {
|
||||
rlog.SetPath(c.String("log"))
|
||||
xlog.SetPath(c.String("log"))
|
||||
|
||||
if c.Bool("verbose") {
|
||||
xlog.Verbose()
|
||||
}
|
||||
|
||||
cfg := config.Parse(c)
|
||||
|
||||
@@ -157,6 +161,11 @@ func main() {
|
||||
Name: "local-auth",
|
||||
Usage: "need auth for local",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "verbose",
|
||||
Aliases: []string{"V"},
|
||||
Usage: "more detailed output",
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
runRttys(c)
|
||||
|
||||
Reference in New Issue
Block a user