mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-22 11:41:38 +00:00
Unify logging by using logrus for jetstream logs (#2976)
I guess tests for the logging is rather unusual so I omitted tests for this change. * [x] I have added Go unit tests or [Complement integration tests](https://github.com/matrix-org/complement) for this PR _or_ I have justified why this PR doesn't need tests * [x] Pull request includes a [sign off below using a legally identifiable name](https://matrix-org.github.io/dendrite/development/contributing#sign-off) _or_ I have already signed off privately Signed-off-by: `David Schneider <dsbrng25b@gmail.com>` --------- Signed-off-by: David Schneider <dsbrng25b@gmail.com>
This commit is contained in:
parent
d34277a6c0
commit
e6aa0955ff
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.Warnf(format, v...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *LogAdapter) Fatalf(format string, v ...interface{}) {
|
||||||
|
l.entry.Fatalf(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...)
|
||||||
|
}
|
@ -40,7 +40,7 @@ func (s *NATSInstance) Prepare(process *process.ProcessContext, cfg *config.JetS
|
|||||||
}
|
}
|
||||||
if s.Server == nil {
|
if s.Server == nil {
|
||||||
var err error
|
var err error
|
||||||
s.Server, err = natsserver.NewServer(&natsserver.Options{
|
opts := &natsserver.Options{
|
||||||
ServerName: "monolith",
|
ServerName: "monolith",
|
||||||
DontListen: true,
|
DontListen: true,
|
||||||
JetStream: true,
|
JetStream: true,
|
||||||
@ -49,11 +49,12 @@ func (s *NATSInstance) Prepare(process *process.ProcessContext, cfg *config.JetS
|
|||||||
MaxPayload: 16 * 1024 * 1024,
|
MaxPayload: 16 * 1024 * 1024,
|
||||||
NoSigs: true,
|
NoSigs: true,
|
||||||
NoLog: cfg.NoLog,
|
NoLog: cfg.NoLog,
|
||||||
})
|
}
|
||||||
|
s.Server, err = natsserver.NewServer(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
s.ConfigureLogger()
|
s.SetLogger(NewLogAdapter(), opts.Debug, opts.Trace)
|
||||||
go func() {
|
go func() {
|
||||||
process.ComponentStarted()
|
process.ComponentStarted()
|
||||||
s.Start()
|
s.Start()
|
||||||
|
Loading…
Reference in New Issue
Block a user