in logger/buffered_logger.go [93:137]
func (bl *bufferedLogger) Start(
ctx context.Context,
uid int,
gid int,
cleanupTime *time.Duration,
ready func() error,
) error {
pipeNameToPipe, err := bl.l.GetPipes()
if err != nil {
return err
}
errGroup, ctx := errgroup.WithContext(ctx)
// Start the goroutine of underlying log driver to consume logs from ring buffer and
// send logs to destination when there's any.
errGroup.Go(func() error {
debug.SendEventsToLog(DaemonName, "Starting consuming logs from ring buffer", debug.INFO, 0)
return bl.sendLogMessagesToDestination(uid, gid, cleanupTime)
})
// Start reading logs from container pipes.
for pn, p := range pipeNameToPipe {
// Copy pn and p to new variables source and pipe, accordingly.
source := pn
pipe := p
errGroup.Go(func() error {
logErr := bl.saveLogMessagesToRingBuffer(ctx, pipe, source, uid, gid)
if logErr != nil {
err := errors.Wrapf(logErr, "failed to send logs from pipe %s", source)
debug.SendEventsToLog(DaemonName, err.Error(), debug.ERROR, 1)
return err
}
return nil
})
}
// Signal that the container is ready to be started
if err := ready(); err != nil {
return errors.Wrap(err, "failed to check container ready status")
}
// Wait() will return the first error it receives.
return errGroup.Wait()
}