Documentation ¶
Index ¶
- Constants
- func Debug(ctx context.Context, msg string)
- func Debugf(ctx context.Context, template string, args ...any)
- func Debugw(ctx context.Context, msg string, keysAndValues ...any)
- func Error(ctx context.Context, msg string)
- func Errorf(ctx context.Context, template string, args ...any)
- func Errorw(ctx context.Context, msg string, keysAndValues ...any)
- func Fatal(ctx context.Context, msg string)
- func Fatalf(ctx context.Context, template string, args ...any)
- func Fatalw(ctx context.Context, msg string, keysAndValues ...any)
- func Info(ctx context.Context, msg string)
- func Infof(ctx context.Context, template string, args ...any)
- func Infow(ctx context.Context, msg string, keysAndValues ...any)
- func NewLogger(config Configuration) (err error)
- func NoCTX() *zapLogger
- func Panic(ctx context.Context, msg string)
- func Panicf(ctx context.Context, template string, args ...any)
- func Panicw(ctx context.Context, msg string, keysAndValues ...any)
- func Warn(ctx context.Context, msg string)
- func Warnf(ctx context.Context, template string, args ...any)
- func Warnw(ctx context.Context, msg string, keysAndValues ...any)
- type BaseFields
- type Configuration
Constants ¶
const ( // DEBUG has verbose message DEBUG = "debug" // INFO is default log level INFO = "info" // WARN is for logging messages about possible issues WARN = "warn" // ERROR is for logging errors ERROR = "error" // FATAL is for logging fatal messages. The sytem shutsdown after logging the message. FATAL = "fatal" )
Variables ¶
This section is empty.
Functions ¶
func Debugw ¶
Debugw logs a message with some additional context, With key and values, example: log.Debugw("message", "url", url, "attempt", 3) Keys in key-value pairs should be strings.
func Errorw ¶
Errorw logs a message with some additional context, With key and values, example: log.Errorw("message", "url", url, "attempt", 3) Keys in key-value pairs should be strings.
func Fatalw ¶
Fatalw logs a message with some additional context, With key and values, example: log.Fatalw("message", "url", url, "attempt", 3) Keys in key-value pairs should be strings.
func Infow ¶
Infow logs a message with some additional context, With key and values, example: log.Infow("message", "url", url, "attempt", 3) Keys in key-value pairs should be strings.
func NewLogger ¶
func NewLogger(config Configuration) (err error)
NewLogger returns an instance of logger
func NoCTX ¶ added in v0.3.0
func NoCTX() *zapLogger
NoCTX allows access to log functions without the need to provide a context variable
func Panicw ¶
Panicw logs a message with some additional context, With key and values, example: log.Panicw("message", "url", url, "attempt", 3) Keys in key-value pairs should be strings.
Types ¶
type BaseFields ¶
BaseFields represents the base fields for create the basic fields of logger.
type Configuration ¶
type Configuration struct { IsJSON bool Level string BaseFields BaseFields CTXFields map[any]string }
Configuration stores the config for the logger For some loggers there can only be one level across writers, for such the level of Console is picked by default
The CTXFields value maps the fields that the logger should look for in the context to its correspondent field in the logger. Ex.:
Configuration{ CTXFields: map[any]string{ 0: "request_id" } }
when loggin, will look for the value stored in the 0 key in the provided context, and log it on the "request_id" field, alongside the log message and information.
By default, if the CTX fields are specified or not, the lib will search for a request id in the context