()
| 38 | } |
| 39 | |
| 40 | func (lw *AsyncLogWriter) Start() { |
| 41 | lw.currDate = time.Now().Format("2006-01-02") |
| 42 | |
| 43 | if lw.msg == nil { |
| 44 | if len(lw.DirPath) > 0 { |
| 45 | err := os.MkdirAll(lw.DirPath, os.ModePerm) |
| 46 | if err != nil { |
| 47 | fmt.Printf("Warning: AsyncLogWriter cannot create directory %s (%v). Using current working directory instead.\n", lw.DirPath, err) |
| 48 | lw.DirPath = "" |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | lw.msg = make(chan []byte, LogQueueSize) |
| 53 | lw.wg.Add(1) |
| 54 | go lw.writeRoutine() |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | // async writer |
| 59 | // must be initiated first, implements atomic write |
no test coverage detected