cmd: windows log file workaround (#2979)
This commit is contained in:
parent
0d4fd6ceeb
commit
0ccae6b061
@ -5,6 +5,7 @@ package process
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
@ -32,6 +33,17 @@ var (
|
|||||||
logOutput = flag.String("log.output", "stderr", "can be stdout, stderr, or a filename")
|
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 isDev() bool { return cfgstruct.DefaultsType() != "release" }
|
||||||
|
|
||||||
func newLogger() (*zap.Logger, error) {
|
func newLogger() (*zap.Logger, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user