GODT-1816: Connect Gluon Logs to bridge Logs
Ensure the IMAP commands and SMTP commands are logged to trace channels with an entry so they are recognizable as before.
This commit is contained in:
committed by
James Houlahan
parent
03e14154a6
commit
f01c70e506
16
internal/logging/imap_logger.go
Normal file
16
internal/logging/imap_logger.go
Normal file
@ -0,0 +1,16 @@
|
||||
package logging
|
||||
|
||||
import "github.com/sirupsen/logrus"
|
||||
|
||||
// IMAPLogger implements the writer interface for Gluon IMAP logs
|
||||
type IMAPLogger struct {
|
||||
l *logrus.Entry
|
||||
}
|
||||
|
||||
func NewIMAPLogger() *IMAPLogger {
|
||||
return &IMAPLogger{l: logrus.WithField("pkg", "IMAP")}
|
||||
}
|
||||
|
||||
func (l *IMAPLogger) Write(p []byte) (n int, err error) {
|
||||
return l.l.WriterLevel(logrus.TraceLevel).Write(p)
|
||||
}
|
||||
35
internal/logging/smtp_logger.go
Normal file
35
internal/logging/smtp_logger.go
Normal file
@ -0,0 +1,35 @@
|
||||
package logging
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// SMTPErrorLogger implements go-smtp/logger interface.
|
||||
type SMTPErrorLogger struct {
|
||||
l *logrus.Entry
|
||||
}
|
||||
|
||||
func NewSMTPLogger() *SMTPErrorLogger {
|
||||
return &SMTPErrorLogger{l: logrus.WithField("pkg", "SMTP")}
|
||||
}
|
||||
|
||||
func (s *SMTPErrorLogger) Printf(format string, args ...interface{}) {
|
||||
s.l.Errorf(format, args...)
|
||||
}
|
||||
|
||||
func (s *SMTPErrorLogger) Println(args ...interface{}) {
|
||||
s.l.Errorln(args...)
|
||||
}
|
||||
|
||||
// SMTPDebugLogger implements the writer interface for debug SMTP logs
|
||||
type SMTPDebugLogger struct {
|
||||
l *logrus.Entry
|
||||
}
|
||||
|
||||
func NewSMTPDebugLogger() *SMTPDebugLogger {
|
||||
return &SMTPDebugLogger{l: logrus.WithField("pkg", "SMTP")}
|
||||
}
|
||||
|
||||
func (l *SMTPDebugLogger) Write(p []byte) (n int, err error) {
|
||||
return l.l.WriterLevel(logrus.TraceLevel).Write(p)
|
||||
}
|
||||
Reference in New Issue
Block a user