MCPcopy Index your code
hub / github.com/aceld/zinx / New

Function New

zutils/witer.go:42–61  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

40}
41
42func New(path string) *Writer {
43 w := &Writer{
44 fpath: path, //dir1/dir2/app.log
45 mu: sync.Mutex{},
46 }
47 w.fdir = filepath.Dir(w.fpath) //dir1/dir2
48 w.fsuffix = filepath.Ext(w.fpath) //.log
49 w.fname = strings.TrimSuffix(filepath.Base(w.fpath), w.fsuffix) //app
50 if w.fsuffix == "" {
51 w.fsuffix = ".log"
52 }
53 if w.zipsuffix == "" {
54 w.zipsuffix = ".zip"
55 }
56 w.maxSize = sizeMiB * defMaxSize
57 w.maxAge = defMaxAge
58 os.MkdirAll(filepath.Dir(w.fpath), 0755)
59 go w.daemon()
60 return w
61}
62func (w *Writer) daemon() {
63 for range time.NewTicker(time.Second * 5).C {
64 w.flush()

Callers 1

SetLogFileMethod · 0.92

Calls 1

daemonMethod · 0.95

Tested by

no test coverage detected