mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-21 04:53:14 -06:00
Unify logging by using logrus for jetstrem logs
Signed-off-by: David Schneider <dsbrng25b@gmail.com>
This commit is contained in:
parent
11d9b9db0e
commit
87a2068e1a
42
setup/jetstream/log.go
Normal file
42
setup/jetstream/log.go
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
package jetstream
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/nats-io/nats-server/v2/server"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ server.Logger = &LogAdapter{}
|
||||||
|
|
||||||
|
type LogAdapter struct {
|
||||||
|
entry *logrus.Entry
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewLogAdapter() *LogAdapter {
|
||||||
|
return &LogAdapter{
|
||||||
|
entry: logrus.StandardLogger().WithField("component", "jetstream"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *LogAdapter) Noticef(format string, v ...interface{}) {
|
||||||
|
l.entry.Infof(format, v...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *LogAdapter) Warnf(format string, v ...interface{}) {
|
||||||
|
l.entry.Errorf(format, v...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *LogAdapter) Fatalf(format string, v ...interface{}) {
|
||||||
|
l.entry.Errorf(format, v...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *LogAdapter) Errorf(format string, v ...interface{}) {
|
||||||
|
l.entry.Errorf(format, v...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *LogAdapter) Debugf(format string, v ...interface{}) {
|
||||||
|
l.entry.Debugf(format, v...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *LogAdapter) Tracef(format string, v ...interface{}) {
|
||||||
|
l.entry.Tracef(format, v...)
|
||||||
|
}
|
||||||
|
|
@ -53,7 +53,7 @@ func (s *NATSInstance) Prepare(process *process.ProcessContext, cfg *config.JetS
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
s.ConfigureLogger()
|
s.SetLogger(NewLogAdapter(), false, false)
|
||||||
go func() {
|
go func() {
|
||||||
process.ComponentStarted()
|
process.ComponentStarted()
|
||||||
s.Start()
|
s.Start()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue