it_worker365

   ::  ::  ::  ::  :: 管理

默认100毫秒刷一次盘,可以通过--output-file-flush-interval

func NewFileOutput(pathTemplate string, config *FileOutputConfig) *FileOutput {
    o := new(FileOutput)
    o.pathTemplate = pathTemplate
    o.config = config
    o.updateName()

    if strings.Contains(pathTemplate, "%r") {
        o.requestPerFile = true
    }

    if config.FlushInterval == 0 {
        config.FlushInterval = 100 * time.Millisecond
    }

    go func() {
        for {
            time.Sleep(config.FlushInterval)
            if o.IsClosed() {
                break
            }
            o.updateName()
            o.flush()
        }
    }()

    return o
}

 

posted on 2021-08-08 13:07  it_worker365  阅读(70)  评论(0编辑  收藏  举报