Documentation
¶
Index ¶
- Constants
- func AddMiddleLayers(middlelayers ...MiddleLayer)
- func Debug(ctx context.Context, format string, a ...any)
- func Error(ctx context.Context, format string, a ...any)
- func Fatal(ctx context.Context, format string, a ...any)
- func Info(ctx context.Context, format string, a ...any)
- func Infof(ctx context.Context, format string, fields *Fields)
- func Infow(ctx context.Context, message string, fs *Fields)
- func Panic(ctx context.Context, format string, a ...any)
- func Warn(ctx context.Context, format string, a ...any)
- type BaseLogger
- type Build
- type Config
- type Field
- type Fields
- type LogLevel
- type Logger
- type MiddleLayer
- type RequestContext
Constants ¶
View Source
const (
RequestContextKey string = "RequestContext"
)
Variables ¶
This section is empty.
Functions ¶
func AddMiddleLayers ¶
func AddMiddleLayers(middlelayers ...MiddleLayer)
Types ¶
type BaseLogger ¶ added in v1.2.0
type BaseLogger interface {
Info(ctx context.Context, format string, a ...any)
Error(ctx context.Context, format string, a ...any)
Warn(ctx context.Context, format string, a ...any)
Debug(ctx context.Context, format string, a ...any)
Panic(ctx context.Context, format string, a ...any)
Fatal(ctx context.Context, format string, a ...any)
}
type Config ¶
type Config struct {
AppName string `yaml:"AppName" json:"AppName" name:"AppName" type:"string" description:"Application Name" required:"true"`
Build Build `yaml:"Build" json:"Build" name:"Build" type:"choice" description:"Build Type" choices:"prod,dev"`
Level LogLevel `yaml:"Level" json:"Level" name:"Level" type:"choice" description:"Log Level" choices:"debug,info,warn,error,panic,fatal"`
// contains filtered or unexported fields
}
Build : if prod it will set to prod else dev
func (Config) InitiateLogger ¶
type Fields ¶
type Fields struct {
// contains filtered or unexported fields
}
func RequestMiddleLayer ¶
type LogLevel ¶
type LogLevel string
const ( DebugLevel LogLevel = "debug" // InfoLevel is the default logging priority. InfoLevel LogLevel = "info" // WarnLevel logs are more important than Info, but don't need individual // human review. WarnLevel LogLevel = "warn" // ErrorLevel logs are high-priority. If an application is running smoothly, // it shouldn't generate any error-level logs. ErrorLevel LogLevel = "error" // DPanicLevel logs are particularly important errors. In development the // logger panics after writing the message. PanicLevel LogLevel = "panic" // FatalLevel logs a message, then calls os.Exit(1). FatalLevel LogLevel = "fatal" )
type Logger ¶ added in v1.2.0
type Logger interface {
BaseLogger
Infof(ctx context.Context, format string, fields *Fields)
Debugf(ctx context.Context, format string, fields *Fields)
Errorf(ctx context.Context, format string, fields *Fields)
Warnf(ctx context.Context, format string, fields *Fields)
Panicf(ctx context.Context, format string, fields *Fields)
Fatalf(ctx context.Context, format string, fields *Fields)
AddMiddleLayers(middlelayers ...MiddleLayer)
ReplaceMiddleLayers(middlelayers ...MiddleLayer)
ChangeConfig(config *Config) error
}
type MiddleLayer ¶
Click to show internal directories.
Click to hide internal directories.