We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug 配置文件读取失败或解析失败情况下,logger.Fatal 会 panic
To Reproduce ./ferry server -c <不存在的配置路径>
Expected behavior 正常提示配置文件不存在或配置文件解析失败
Screenshots
❯ ./ferry server -c /tmp/1 2023/12/13 17:48:00 starting api server panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x10044c055] goroutine 1 [running]: go.uber.org/zap.(*SugaredLogger).log(0x0, 0x5, {0x0?, 0x0?}, {0xc0025bfd18?, 0x100011b05?, 0x10?}, {0x0, 0x0, 0x0}) /Users/lafrinte/go/pkg/mod/go.uber.org/zap@v1.10.0/sugar.go:233 +0xf5 go.uber.org/zap.(*SugaredLogger).Fatal(...) /Users/lafrinte/go/pkg/mod/go.uber.org/zap@v1.10.0/sugar.go:128 ferry/pkg/logger.Fatal(...) /Users/lafrinte/Downloads/ferry/pkg/logger/logger.go:116 ferry/tools/config.ConfigSetup({0x7ff7bfeff172?, 0x1?}) /Users/lafrinte/Downloads/ferry/tools/config/config.go:23 +0x11e ferry/cmd/api.setup() /Users/lafrinte/Downloads/ferry/cmd/api/server.go:56 +0x25 ferry/cmd/api.glob..func1(0xc000782800?, {0x10108da10?, 0x4?, 0x10108da14?}) /Users/lafrinte/Downloads/ferry/cmd/api/server.go:34 +0x14 github.com/spf13/cobra.(*Command).execute(0x1030964a0, {0xc00183a6e0, 0x2, 0x2}) /Users/lafrinte/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:835 +0x603 github.com/spf13/cobra.(*Command).ExecuteC(0x103096200) /Users/lafrinte/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x389 github.com/spf13/cobra.(*Command).Execute(...) /Users/lafrinte/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887 ferry/cmd.Execute() /Users/lafrinte/Downloads/ferry/cmd/cobra.go:39 +0x1a main.main() /Users/lafrinte/Downloads/ferry/main.go:8 +0xf
Desktop (please complete the following information):
Additional context
func ConfigSetup(path string) { viper.SetConfigFile(path) content, err := ioutil.ReadFile(path) if err != nil { logger.Fatal(fmt.Sprintf("Read config file fail: %s", err.Error())) } //Replace environment variables err = viper.ReadConfig(strings.NewReader(os.ExpandEnv(string(content)))) if err != nil { logger.Fatal(fmt.Sprintf("Parse config file fail: %s", err.Error())) } ... // 日志配置 logger.Init() }
logger.Init()前,logger.log 是空指针,logger.Fatal会 panic
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
配置文件读取失败或解析失败情况下,logger.Fatal 会 panic
To Reproduce
./ferry server -c <不存在的配置路径>
Expected behavior
正常提示配置文件不存在或配置文件解析失败
Screenshots
Desktop (please complete the following information):
Additional context
logger.Init()前,logger.log 是空指针,logger.Fatal会 panic
The text was updated successfully, but these errors were encountered: