mirror of
https://github.com/status-im/status-go.git
synced 2025-01-09 22:26:30 +00:00
eeca435064
Update vendor Integrate rendezvous into status node Add a test with failover using rendezvous Use multiple servers in client Use discovery V5 by default and test that node can be started with rendezvous discovet Fix linter Update rendezvous client to one with instrumented stream Address feedback Fix test with updated topic limits Apply several suggestions Change log to debug for request errors because we continue execution Remove web3js after rebase Update rendezvous package
66 lines
1.8 KiB
Go
66 lines
1.8 KiB
Go
// Copyright 2013, Örjan Persson. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package logging
|
|
|
|
// TODO remove Level stuff from the multi logger. Do one thing.
|
|
|
|
// multiLogger is a log multiplexer which can be used to utilize multiple log
|
|
// backends at once.
|
|
type multiLogger struct {
|
|
backends []LeveledBackend
|
|
}
|
|
|
|
// MultiLogger creates a logger which contain multiple loggers.
|
|
func MultiLogger(backends ...Backend) LeveledBackend {
|
|
var leveledBackends []LeveledBackend
|
|
for _, backend := range backends {
|
|
leveledBackends = append(leveledBackends, AddModuleLevel(backend))
|
|
}
|
|
return &multiLogger{leveledBackends}
|
|
}
|
|
|
|
// Log passes the log record to all backends.
|
|
func (b *multiLogger) Log(level Level, calldepth int, rec *Record) (err error) {
|
|
for _, backend := range b.backends {
|
|
if backend.IsEnabledFor(level, rec.Module) {
|
|
// Shallow copy of the record for the formatted cache on Record and get the
|
|
// record formatter from the backend.
|
|
r2 := *rec
|
|
if e := backend.Log(level, calldepth+1, &r2); e != nil {
|
|
err = e
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// GetLevel returns the highest level enabled by all backends.
|
|
func (b *multiLogger) GetLevel(module string) Level {
|
|
var level Level
|
|
for _, backend := range b.backends {
|
|
if backendLevel := backend.GetLevel(module); backendLevel > level {
|
|
level = backendLevel
|
|
}
|
|
}
|
|
return level
|
|
}
|
|
|
|
// SetLevel propagates the same level to all backends.
|
|
func (b *multiLogger) SetLevel(level Level, module string) {
|
|
for _, backend := range b.backends {
|
|
backend.SetLevel(level, module)
|
|
}
|
|
}
|
|
|
|
// IsEnabledFor returns true if any of the backends are enabled for it.
|
|
func (b *multiLogger) IsEnabledFor(level Level, module string) bool {
|
|
for _, backend := range b.backends {
|
|
if backend.IsEnabledFor(level, module) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|