mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-02-02 14:58:14 -05:00
support output log to file
This commit is contained in:
parent
24423d892c
commit
22365bc1ce
@ -1,19 +1,17 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/InazumaV/V2bX/conf"
|
||||
vCore "github.com/InazumaV/V2bX/core"
|
||||
"github.com/InazumaV/V2bX/limiter"
|
||||
"github.com/InazumaV/V2bX/node"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"syscall"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
vCore "github.com/InazumaV/V2bX/core"
|
||||
|
||||
"github.com/InazumaV/V2bX/conf"
|
||||
"github.com/InazumaV/V2bX/limiter"
|
||||
"github.com/InazumaV/V2bX/node"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -56,6 +54,16 @@ func serverHandle(_ *cobra.Command, _ []string) {
|
||||
case "error":
|
||||
log.SetLevel(log.ErrorLevel)
|
||||
}
|
||||
if c.LogConfig.Output != "" {
|
||||
w := &lumberjack.Logger{
|
||||
Filename: c.LogConfig.Output,
|
||||
MaxSize: 100,
|
||||
MaxBackups: 3,
|
||||
MaxAge: 28,
|
||||
Compress: true,
|
||||
}
|
||||
log.SetOutput(w)
|
||||
}
|
||||
limiter.Init()
|
||||
log.Info("Start V2bX...")
|
||||
vc, err := vCore.NewCore(c.CoresConfig)
|
||||
|
@ -2,7 +2,10 @@
|
||||
"Log": {
|
||||
// V2bX 的日志配置,独立于各 Core 的 log 配置
|
||||
|
||||
"Level": "error"
|
||||
// 日志等级,info, warn, error, none
|
||||
"Level": "error",
|
||||
// 日志输出路径,默认输出到标准输出
|
||||
"Output": ""
|
||||
},
|
||||
"Cores": [
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user