# README
Logging in ImageKit SDK
The default logger in ImageKit Go SDK is go log
.
You can use any log library by overwriting the standard SDK logging functions.
Using logrus with the SDK
package main
import (
"github.com/dhaval070/imagekit-go"
"github.com/sirupsen/logrus"
"log"
)
func main() {
var imgkit, err = imagekit.New()
if err != nil {
log.Fatalf("Failed to intialize ImageKit, %v", err)
}
// Initialize your logger somewhere in your code.
// Set imgkit.Logger.Writer with logrus instance
var logger = logrus.New()
imgkit.Logger.Writer = logger.WithField("source", "ImageKit")
}
Using Zap with the SDK
package main
import (
"github.com/dhaval070/imagekit-go"
"go.uber.org/zap"
"log"
)
func main() {
var imgkit, err = ImageKit.New()
if err != nil {
log.Fatalf("Failed to intialize ImageKit, %v", err)
}
// Initialize your logger somewhere in your code.
// Set ImageKit.Logger.Writer with zap.SugaredLogger instance
var zapLogger, _ = zap.NewDevelopment()
imgkit.Logger.Writer = zapLogger.Sugar().With("source", "ImageKit")
}
Logging level
You can change logging level with the Logger.SetLevel()
function.
Possible values:
logger.NONE
- disabling logging from the SDKlogger.ERROR
- enable logging only for error messageslogger.DEBUG
- enable debug logs
# Functions
New returns a new logger instance.
# Interfaces
LogWriter is an interface for a log writer.
# Type aliases
Level represents the level of the logger.