1
0
forked from lug/matterbridge

Update mattermost library (#2152)

* Update mattermost library

* Fix linting
This commit is contained in:
Wim
2024-05-24 23:08:09 +02:00
committed by GitHub
parent 65d78e38af
commit d16645c952
1003 changed files with 89451 additions and 114025 deletions

View File

@@ -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: