Hi all. For the Golang SDK. Doesn’t seem to turn...
# general
p
Hi all. For the Golang SDK. Doesn’t seem to turn off the logging.
Copy code
pc, err := pulsar.NewClient(pulsar.ClientOptions{
		URL:               url,
		OperationTimeout:  b.config.OperationTimeout,
		ConnectionTimeout: b.config.ConnectionTimeout,
		Logger:            nil,
	})
Is there a way to turn this off?
Copy code
INFO[0057] Connected producer                            cnx="127.0.0.1:52155 -> 127.0.0.1:6651" epoch=0 topic="<persistent://public/default/centrifugo.control>"
INFO[0057] Created producer                              cnx="127.0.0.1:52155 -> 127.0.0.1:6651" producerID=20 producer_name=producer-control topic="<persistent://public/default/centrifugo.control>"
INFO[0057] Closing producer                              producerID=20 producer_name=producer-control topic="<persistent://public/default/centrifugo.control>"
INFO[0057] Closed producer                               producerID=20 producer_name=producer-control topic="<persistent://public/default/centrifugo.control>"
Thanks
This is what I concluded with. Since I could not really turn off. I simply redirected to the apps own logging:
Copy code
// CustomWriter is an io.Writer that forwards logs to centrifugo.
type CustomWriter struct {
	node *centrifuge.Node
}

// Write implements the io.Writer interface.
func (cw *CustomWriter) Write(p []byte) (n int, err error) {
	whitelistMessages := []string{
		"Pulsar Broker connected to",
	}

	message := fmt.Sprintf("%v", string(p))

	for _, ignoreMsg := range whitelistMessages {
		if message != ignoreMsg {
			return
		}
	}

	cw.node.Log(centrifuge.NewLogEntry(centrifuge.LogLevelWarn, string(p), nil))
	return len(p), nil
}

func (b *PulsarBroker) Run(h centrifuge.BrokerEventHandler) error {
// Create a custom writer that forwards logs to centrifugo.
	customWriter := &CustomWriter{node: b.node}

	// Setup logger
	logrusLogger := logrus.New()
	logrusLogger.SetOutput(customWriter)

	pc, err := pulsar.NewClient(pulsar.ClientOptions{
		URL:               url,
		OperationTimeout:  b.config.OperationTimeout,
		ConnectionTimeout: b.config.ConnectionTimeout,
		Logger:            log.NewLoggerWithLogrus(logrusLogger),
	})
}
✅ 1
Would be nice if there was a log_test.go file with all the different options