Implemented possible fix for #13

pull/24/head
マリウス 2 years ago
parent 6d35a1d156
commit 7e3dabacb2
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F

@ -3,6 +3,9 @@ package main
import (
"context"
"embed"
"net/url"
"os"
"runtime"
"time"
"log"
@ -18,9 +21,22 @@ import (
var EMBEDFS embed.FS
func NewLogger(filename string) (*zap.Logger, error) {
if runtime.GOOS == "windows" {
zap.RegisterSink("winfile", func(u *url.URL) (zap.Sink, error) {
return os.OpenFile(u.Path[1:], os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
})
}
cfg := zap.NewProductionConfig()
cfg.OutputPaths = []string{
filename,
if runtime.GOOS == "windows" {
cfg.OutputPaths = []string{
"stdout",
"winfile:///" + filename,
}
} else {
cfg.OutputPaths = []string{
filename,
}
}
return cfg.Build()
}

Loading…
Cancel
Save