forked from lug/matterbridge
Update mattermost library (#2152)
* Update mattermost library * Fix linting
This commit is contained in:
24
vendor/github.com/mattermost/logr/v2/logr.go
generated
vendored
24
vendor/github.com/mattermost/logr/v2/logr.go
generated
vendored
@@ -42,6 +42,7 @@ func New(opts ...Option) (*Logr, error) {
|
||||
shutdownTimeout: DefaultShutdownTimeout,
|
||||
flushTimeout: DefaultFlushTimeout,
|
||||
maxPooledBuffer: DefaultMaxPooledBuffer,
|
||||
maxFieldLen: DefaultMaxFieldLength,
|
||||
}
|
||||
|
||||
lgr := &Logr{options: options}
|
||||
@@ -246,6 +247,29 @@ func (lgr *Logr) SetMetricsCollector(collector MetricsCollector, updateFreqMilli
|
||||
// this function either blocks or the log record is dropped, depending on
|
||||
// the result of calling `OnQueueFull`.
|
||||
func (lgr *Logr) enqueue(rec *LogRec) {
|
||||
// check if a limit has been configured
|
||||
if limit := lgr.options.maxFieldLen; limit > 0 {
|
||||
// we limit the message
|
||||
rec.msg = LimitString(rec.msg, limit)
|
||||
|
||||
// then we range over fields to apply the limit
|
||||
for i := range rec.fields {
|
||||
switch rec.fields[i].Type {
|
||||
case StringType:
|
||||
rec.fields[i].String = LimitString(rec.fields[i].String, limit)
|
||||
case StringerType:
|
||||
if v, ok := rec.fields[i].Interface.(fmt.Stringer); ok {
|
||||
rec.fields[i].Interface = &LimitedStringer{
|
||||
Stringer: v,
|
||||
Limit: limit,
|
||||
}
|
||||
}
|
||||
default:
|
||||
// no limits for other field types
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
select {
|
||||
case lgr.in <- rec:
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user