Documentation
¶
Overview ¶
Logger Interface Use instance of logger instead of exported functions
usage example
import ( "errors" "github.com/rudderlabs/rudder-go-kit/config" "github.com/rudderlabs/rudder-go-kit/logger" ) var c = config.New() var loggerFactory = logger.NewFactory(c) var log logger.Logger = loggerFactory.NewLogger() ... log.Error(...)
or if you want to use the default logger factory (not advised):
var log logger.Logger = logger.NewLogger() ... log.Error(...)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLoggingConfig ¶
GetLoggingConfig returns the log levels for default logger factory
func Reset ¶
func Reset()
Reset resets the default logger factory. Shall only be used by tests, until we move to a proper DI framework
func SetLogLevel ¶
SetLogLevel sets the log level for a module for the default logger factory
Types ¶
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory is a factory for creating new loggers
var Default *Factory
default factory instance
func NewFactory ¶
NewFactory creates a new logger factory
func (*Factory) GetLoggingConfig ¶
GetLoggingConfig returns the log levels
func (*Factory) SetLogLevel ¶
SetLogLevel sets the log level for a module
type Logger ¶
type Logger interface { // IsDebugLevel Returns true is debug lvl is enabled IsDebugLevel() bool // Debug level logging. Most verbose logging level. Debug(args ...interface{}) // Debugf does debug level logging similar to fmt.Printf. Most verbose logging level Debugf(format string, args ...interface{}) // Debugw does debug level structured logging. Most verbose logging level Debugw(msg string, keysAndValues ...interface{}) // Info level logging. Use this to log the state of the application. Dont use Logger.Info in the flow of individual events. Use Logger.Debug instead. Info(args ...interface{}) // Infof does info level logging similar to fmt.Printf. Use this to log the state of the application. Dont use Logger.Info in the flow of individual events. Use Logger.Debug instead. Infof(format string, args ...interface{}) // Infof does info level structured logging. Use this to log the state of the application. Dont use Logger.Info in the flow of individual events. Use Logger.Debug instead. Infow(msg string, keysAndValues ...interface{}) // Warn level logging. Use this to log warnings Warn(args ...interface{}) // Warnf does warn level logging similar to fmt.Printf. Use this to log warnings Warnf(format string, args ...interface{}) // Warnf does warn level structured logging. Use this to log warnings Warnw(msg string, keysAndValues ...interface{}) // Error level logging. Use this to log errors which dont immediately halt the application. Error(args ...interface{}) // Errorf does error level logging similar to fmt.Printf. Use this to log errors which dont immediately halt the application. Errorf(format string, args ...interface{}) // Errorf does error level structured logging. Use this to log errors which dont immediately halt the application. Errorw(msg string, keysAndValues ...interface{}) // Fatal level logging. Use this to log errors which crash the application. Fatal(args ...interface{}) // Fatalf does fatal level logging similar to fmt.Printf. Use this to log errors which crash the application. Fatalf(format string, args ...interface{}) // Fatalf does fatal level structured logging. Use this to log errors which crash the application. Fatalw(format string, keysAndValues ...interface{}) LogRequest(req *http.Request) // Child creates a child logger with the given name Child(s string) Logger // With adds the provided key value pairs to the logger context With(args ...interface{}) Logger }
var NOP Logger = nop{}
Directories
¶
Path | Synopsis |
---|---|
Package mock_logger is a generated GoMock package.
|
Package mock_logger is a generated GoMock package. |
Click to show internal directories.
Click to hide internal directories.