github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/daemon/logger/logger_error.go (about)

     1  package logger
     2  
     3  import (
     4  	"github.com/sirupsen/logrus"
     5  	"golang.org/x/time/rate"
     6  )
     7  
     8  // Rates based on journald defaults of 10,000 messages in 30s.
     9  // reference: https://www.freedesktop.org/software/systemd/man/journald.conf.html#RateLimitIntervalSec=
    10  var logErrorLimiter = rate.NewLimiter(333, 333)
    11  
    12  // logDriverError logs errors produced by log drivers to the daemon logs. It also increments the logWritesFailedCount
    13  // metric.
    14  // Logging to the daemon logs is limited to 333 operations per second at most. If this limit is exceeded, the
    15  // logWritesFailedCount is still counted, but logging to the daemon logs is omitted in order to prevent disk saturation.
    16  func logDriverError(loggerName, msgLine string, logErr error) {
    17  	logWritesFailedCount.Inc(1)
    18  	if logErrorLimiter.Allow() {
    19  		logrus.WithError(logErr).
    20  			WithField("driver", loggerName).
    21  			WithField("message", msgLine).
    22  			Errorf("Error writing log message")
    23  	}
    24  }