-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_windows.go
44 lines (34 loc) · 944 Bytes
/
log_windows.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package jsonlog
import (
"fmt"
"log"
"os"
"path"
"github.com/rs/zerolog"
)
//newJSONLog ...
func newJSONLog(filepath, confpath string, arg ...interface{}) *zerolog.Logger {
newfilepath, filename := path.Split(filepath)
configPath, configName := path.Split(confpath)
l := zerolog.New(newOut(newfilepath, filename, configPath, configName, arg...)).With().Timestamp().Logger()
return &l
}
//logClose ...
func logClose(sg os.Signal) {
}
// newInput ...
func newOut(newfilepath, filename, configPath, configName string, arg ...interface{}) *writer {
os.MkdirAll(newfilepath, os.ModePerm)
runF, err := os.OpenFile(path.Join(newfilepath, filename), os.O_CREATE|os.O_APPEND|os.O_WRONLY, os.ModePerm)
if err != nil {
fmt.Println("Error in Open run file: ", err)
os.Exit(1)
}
pnewW, err := newWriter(configPath, configName+"level", arg...)
if err != nil {
log.Println(err)
os.Exit(1)
}
pnewW.run = runF
return pnewW
}