| 80 | } |
| 81 | |
| 82 | func (this *LogWriter) MakeLogTimePath() { |
| 83 | now := time.Now() |
| 84 | dirName := fmt.Sprintf("%d-%02d-%02d", |
| 85 | now.Year(), |
| 86 | now.Month(), |
| 87 | now.Day()) |
| 88 | |
| 89 | this.path = path.Join(this.init_path, dirName) |
| 90 | |
| 91 | this.MakePath() |
| 92 | zero_time := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()) |
| 93 | delayTime := 24*60*60 - (now.Unix() - zero_time.Unix()) |
| 94 | |
| 95 | if this.dayTimer == nil { |
| 96 | this.dayTimer = time.NewTimer(time.Duration(delayTime) * time.Second) |
| 97 | } else { |
| 98 | this.dayTimer.Reset(time.Duration(delayTime) * time.Second) |
| 99 | } |
| 100 | this.syncLog() |
| 101 | this.filter = make(map[string]*FileWriter) |
| 102 | } |
| 103 | |
| 104 | func (this *LogWriter) Run(b bool) { |
| 105 | defer this.Recover() |