logTask logs the set of updates from a given task to the sink, then logs a "done." message, and then marks the task as done. By default, the *Logger throttles log entry updates to once per the duration of time specified by `l.throttle time.Duration`. If the duration if 0, or the task is "durable"
(task Task)
| 213 | // github.com/git-lfs/git-lfs/tasklog#DurableTask), then all entries will be |
| 214 | // logged. |
| 215 | func (l *Logger) logTask(task Task) { |
| 216 | defer l.wg.Done() |
| 217 | |
| 218 | logAll := !task.Throttled() |
| 219 | var last time.Time |
| 220 | |
| 221 | var update *Update |
| 222 | for update = range task.Updates() { |
| 223 | if !tty(os.Stdout) && !l.forceProgress { |
| 224 | continue |
| 225 | } |
| 226 | if logAll || l.throttle == 0 || !update.Throttled(last.Add(l.throttle)) { |
| 227 | l.logLine(update.S) |
| 228 | last = update.At |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | if update != nil { |
| 233 | // If a task sent no updates, the last recorded update will be |
| 234 | // nil. Given this, only log a message when there was at least |
| 235 | // (1) update. |
| 236 | l.log(fmt.Sprintf("%s, done.\n", update.S)) |
| 237 | } |
| 238 | |
| 239 | if v, ok := task.(interface { |
| 240 | // OnComplete is called after the Task "task" is closed, but |
| 241 | // before new tasks are accepted. |
| 242 | OnComplete() |
| 243 | }); ok { |
| 244 | // If the Task implements this interface, call it and block |
| 245 | // before accepting new tasks. |
| 246 | v.OnComplete() |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | // logLine writes a complete line and moves the cursor to the beginning of the |
| 251 | // line. |