github.com/masterhung0112/hk_server/v5@v5.0.0-20220302090640-ec71aef15e1c/shared/mlog/errors.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See LICENSE.txt for license information. 3 4 package mlog 5 6 import ( 7 "github.com/mattermost/logr" 8 ) 9 10 // onLoggerError is called when the logging system encounters an error, 11 // such as a target not able to write records. The targets will keep trying 12 // however the error will be logged with a dedicated level that can be output 13 // to a safe/always available target for monitoring or alerting. 14 func onLoggerError(err error) { 15 Log(LvlLogError, "advanced logging error", Err(err)) 16 } 17 18 // onQueueFull is called when the main logger queue is full, indicating the 19 // volume and frequency of log record creation is too high for the queue size 20 // and/or the target latencies. 21 func onQueueFull(rec *logr.LogRec, maxQueueSize int) bool { 22 Log(LvlLogError, "main queue full, dropping record", Any("rec", rec)) 23 return true // drop record 24 } 25 26 // onTargetQueueFull is called when the main logger queue is full, indicating the 27 // volume and frequency of log record creation is too high for the target's queue size 28 // and/or the target latency. 29 func onTargetQueueFull(target logr.Target, rec *logr.LogRec, maxQueueSize int) bool { 30 Log(LvlLogError, "target queue full, dropping record", String("target", ""), Any("rec", rec)) 31 return true // drop record 32 }