Documentation ¶
Overview ¶
Logger Interface Use instance of logger instead of exported functions
usage example
import (
"errors" "github.com/serviceexchange/server/utils/logger"
)
var log logger.LoggerI = &logger.LoggerT{}
or
var log logger.LoggerI = logger.NewLogger()
...
log.Error(...)
Index ¶
- Variables
- func GetLoggingConfig() map[string]int
- func Init()
- func SetModuleLevel(module, levelStr string) error
- type LoggerI
- type LoggerT
- func (l *LoggerT) Child(s string) LoggerI
- func (l *LoggerT) Debug(args ...interface{})
- func (l *LoggerT) Debugf(format string, args ...interface{})
- func (l *LoggerT) Error(args ...interface{})
- func (l *LoggerT) Errorf(format string, args ...interface{})
- func (l *LoggerT) Fatal(args ...interface{})
- func (l *LoggerT) Fatalf(format string, args ...interface{})
- func (l *LoggerT) Info(args ...interface{})
- func (l *LoggerT) Infof(format string, args ...interface{})
- func (l *LoggerT) IsDebugLevel() bool
- func (l *LoggerT) LogRequest(req *http.Request)
- func (l *LoggerT) Warn(args ...interface{})
- func (l *LoggerT) Warnf(format string, args ...interface{})
- type NOP
- func (NOP) Child(_ string) LoggerI
- func (NOP) Debug(_ ...interface{})
- func (NOP) Debugf(_ string, _ ...interface{})
- func (NOP) Error(_ ...interface{})
- func (NOP) Errorf(_ string, _ ...interface{})
- func (NOP) Fatal(_ ...interface{})
- func (NOP) Fatalf(_ string, _ ...interface{})
- func (NOP) Info(_ ...interface{})
- func (NOP) Infof(_ string, _ ...interface{})
- func (NOP) IsDebugLevel() bool
- func (NOP) LogRequest(_ *http.Request)
- func (NOP) Warn(_ ...interface{})
- func (NOP) Warnf(_ string, _ ...interface{})
Constants ¶
This section is empty.
Variables ¶
var (
Log *zap.SugaredLogger
)
Functions ¶
func GetLoggingConfig ¶
func SetModuleLevel ¶
SetModuleLevel sets log level for a module and it's children Pass empty string for module parameter for resetting root logging level
Types ¶
type LoggerI ¶
type LoggerI interface { IsDebugLevel() bool Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) Fatal(args ...interface{}) Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) LogRequest(req *http.Request) Child(s string) LoggerI }
type LoggerT ¶
type LoggerT struct {
// contains filtered or unexported fields
}
func (*LoggerT) Debug ¶
func (l *LoggerT) Debug(args ...interface{})
Debug level logging. Most verbose logging level.
func (*LoggerT) Debugf ¶
Debugf does debug level logging similar to fmt.Printf. Most verbose logging level
func (*LoggerT) Error ¶
func (l *LoggerT) Error(args ...interface{})
Error level logging. Use this to log errors which dont immediately halt the application.
func (*LoggerT) Errorf ¶
Errorf does error level logging similar to fmt.Printf. Use this to log errors which dont immediately halt the application.
func (*LoggerT) Fatal ¶
func (l *LoggerT) Fatal(args ...interface{})
Fatal level logging. Use this to log errors which crash the application.
func (*LoggerT) Fatalf ¶
Fatalf does fatal level logging similar to fmt.Printf. Use this to log errors which crash the application.
func (*LoggerT) Info ¶
func (l *LoggerT) Info(args ...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.
func (*LoggerT) Infof ¶
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.
func (*LoggerT) IsDebugLevel ¶
IsDebugLevel Returns true is debug lvl is enabled
func (*LoggerT) LogRequest ¶
LogRequest reads and logs the request body and resets the body to original state.