cmd: windows log file workaround (#2979)
This commit is contained in:
parent
0d4fd6ceeb
commit
0ccae6b061
@ -5,6 +5,7 @@ package process
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"net/url"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
@ -32,6 +33,17 @@ var (
|
||||
logOutput = flag.String("log.output", "stderr", "can be stdout, stderr, or a filename")
|
||||
)
|
||||
|
||||
func init() {
|
||||
winFileSink := func(u *url.URL) (zap.Sink, error) {
|
||||
// Remove leading slash left by url.Parse()
|
||||
return os.OpenFile(u.Path[1:], os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
|
||||
}
|
||||
err := zap.RegisterSink("winfile", winFileSink)
|
||||
if err != nil {
|
||||
panic("Unable to register winfile sink: " + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func isDev() bool { return cfgstruct.DefaultsType() != "release" }
|
||||
|
||||
func newLogger() (*zap.Logger, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user