MCPcopy
hub / github.com/git-lfs/git-lfs / logTask

Method logTask

tasklog/log.go:215–248  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

213// github.com/git-lfs/git-lfs/tasklog#DurableTask), then all entries will be
214// logged.
215func (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.

Callers 1

consumeMethod · 0.95

Calls 9

ThrottledMethod · 0.95
logLineMethod · 0.95
logMethod · 0.95
ttyFunction · 0.85
OnCompleteMethod · 0.80
ThrottledMethod · 0.65
UpdatesMethod · 0.65
AddMethod · 0.65
DoneMethod · 0.45

Tested by

no test coverage detected