Refactor log
This commit is contained in:
@@ -7,10 +7,10 @@ import (
|
||||
"syscall"
|
||||
|
||||
"github.com/sagernet/sing-box"
|
||||
"github.com/sagernet/sing-box/log"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -23,12 +23,12 @@ var commandRun = &cobra.Command{
|
||||
func run(cmd *cobra.Command, args []string) {
|
||||
configContent, err := os.ReadFile(configPath)
|
||||
if err != nil {
|
||||
logrus.Fatal("read config: ", err)
|
||||
log.Fatal("read config: ", err)
|
||||
}
|
||||
var options option.Options
|
||||
err = json.Unmarshal(configContent, &options)
|
||||
if err != nil {
|
||||
logrus.Fatal("decode config: ", err)
|
||||
log.Fatal("decode config: ", err)
|
||||
}
|
||||
if disableColor {
|
||||
if options.Log == nil {
|
||||
@@ -39,11 +39,11 @@ func run(cmd *cobra.Command, args []string) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
instance, err := box.New(ctx, options)
|
||||
if err != nil {
|
||||
logrus.Fatal("create service: ", err)
|
||||
log.Fatal("create service: ", err)
|
||||
}
|
||||
err = instance.Start()
|
||||
if err != nil {
|
||||
logrus.Fatal("start service: ", err)
|
||||
log.Fatal("start service: ", err)
|
||||
}
|
||||
osSignals := make(chan os.Signal, 1)
|
||||
signal.Notify(osSignals, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
Reference in New Issue
Block a user