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