wagslane / go-rabbitmq

A wrapper of streadway/amqp that provides reconnection logic and sane defaults
https://blog.boot.dev/golang/connecting-to-rabbitmq-in-golang-easy/
MIT License
772 stars 126 forks source link

Custom Logger broken on shutdown #182

Closed brounnoupegreula-7757 closed 3 weeks ago

brounnoupegreula-7757 commented 3 weeks ago

hi i try the example logger, and user uber zap as my custom logger

package logger

import ( "go.uber.org/zap" )

type RabbitMqZapLogger struct {
    Logger *zap.Logger
}

func (l RabbitMqZapLogger) Fatalf(format string, v ...interface{}) {
    l.Logger.Sugar().Fatalf(format, v...)
}

func (l RabbitMqZapLogger) Errorf(format string, v ...interface{}) {
    l.Logger.Sugar().Errorf(format, v...)
}

func (l RabbitMqZapLogger) Warnf(format string, v ...interface{}) {
    l.Logger.Sugar().Warnf(format, v...)
}

func (l RabbitMqZapLogger) Infof(format string, v ...interface{}) {
    l.Logger.Sugar().Infof(format, v...)
}

func (l RabbitMqZapLogger) Debugf(format string, v ...interface{}) {
    l.Logger.Sugar().Debugf(format, v...)
}

but after the app shutdown or interupt by user, look like the connection manager (close function) lost zap formating, any idea why like this?

image

thibleroy commented 3 weeks ago

Hello, Use WithConnectionOptionsLogger connection option?

brounnoupegreula-7757 commented 3 weeks ago

i fix this @thibleroy

WithConnectionOptionsLogger worked :)

thank you