GoGo V4 SDK Troubleshooting Guide

 

These docs are for PubNub 4.0 for Go which is our latest and greatest! For the docs of the older versions of the SDK, please check PubNub 3.0 for Go.

If you have questions about the PubNub for Go SDK, please contact us at support@pubnub.com.

To enable logging you need to init by specifying the logger instance in messaging.NewPubnub.
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)