Merge pull request #2057 from giuseppe/no-reopen-stderr

main: not reopen /dev/stderr
This commit is contained in:
Mrunal Patel 2019-05-14 17:39:28 -07:00 committed by GitHub
commit b9b6cc6e47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

10
main.go
View File

@ -87,7 +87,7 @@ func main() {
}, },
cli.StringFlag{ cli.StringFlag{
Name: "log", Name: "log",
Value: "/dev/stderr", Value: "",
Usage: "set the log file path where internal debug information is written", Usage: "set the log file path where internal debug information is written",
}, },
cli.StringFlag{ cli.StringFlag{
@ -157,9 +157,15 @@ func (f *FatalWriter) Write(p []byte) (n int, err error) {
} }
func createLogConfig(context *cli.Context) logs.Config { func createLogConfig(context *cli.Context) logs.Config {
logFilePath := context.GlobalString("log")
logPipeFd := ""
if logFilePath == "" {
logPipeFd = "2"
}
config := logs.Config{ config := logs.Config{
LogPipeFd: logPipeFd,
LogLevel: logrus.InfoLevel, LogLevel: logrus.InfoLevel,
LogFilePath: context.GlobalString("log"), LogFilePath: logFilePath,
LogFormat: context.GlobalString("log-format"), LogFormat: context.GlobalString("log-format"),
} }
if context.GlobalBool("debug") { if context.GlobalBool("debug") {