Troubleshooting PubNub Go SDK

To enable logging you need to init by specifying the logger instance in messaging.NewPubnub.

Required UUID

Always set the UUID to uniquely identify the user or device that connects to PubNub. This UUID should be persisted, and should remain unchanged for the lifetime of the user or the device. If you don't set the UUID, you won't be able to connect to PubNub.

config = pubnub.NewConfig()
var infoLogger *log.Logger

logfileName := "pubnubMessaging.log"
f, err := os.OpenFile(logfileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
fmt.Println("error opening file: ", err.Error())
fmt.Println("Logging disabled")
} else {
fmt.Println("Logging enabled writing to ", logfileName)
infoLogger = log.New(f, "", log.Ldate|log.Ltime|log.Lshortfile)
config.Log = infoLogger
config.Log.SetPrefix("PubNub := ")
}
pn = pubnub.NewPubNub(config)
Last updated on
On this page