Documentation ¶
Index ¶
Constants ¶
View Source
const ErrorStackLogKey = "_stack"
Variables ¶
View Source
var Any = zap.Any
View Source
var Bool = zap.Bool
View Source
var Debug = global.Debug
View Source
var Duration = zap.Duration
View Source
var Enabled = global.Enabled
View Source
var Err = zap.Error
View Source
var Error = global.Error
View Source
var Info = global.Info
View Source
var Int = zap.Int
View Source
var Int32 = zap.Int32
View Source
var Int64 = zap.Int64
View Source
var Message = global.Message
View Source
var NamedErr = zap.NamedError
View Source
var String = zap.String
View Source
var Time = zap.Time
View Source
var Timep = zap.Timep
View Source
var Times = zap.Times
View Source
var Uint32 = zap.Uint32
View Source
var Uint64 = zap.Uint64
View Source
var Warn = global.Warn
View Source
var With = global.With
View Source
var WithCtx = global.WithCtx
Functions ¶
func FieldToKeyVal ¶
func NewWriter ¶
NewWriter creates a new io.Writer using logger. Logger param is optional and its default value is the global logger.
func SetGlobalLogger ¶
func SetGlobalLogger(l Logger)
Types ¶
type Field ¶
func MapToFields ¶
type Level ¶
type Level int8
Level can use by all drivers to map to the real level of their logger.
func LevelFromString ¶
LevelFromString converts string to log level.
type Logger ¶
type Logger interface { // Core function returns the logger core concrete struct. // this is because sometimes we need to convert one logger // interface to another and need to the concrete logger. Core() any // Enabled returns true if the logger covers the provided log level. // Each level covers itself and all higher logging levels. // For example the InfoLevel level covers WarnLevel and ErrorLevel. Enabled(lvl Level) bool // WithCtx gets the hexa context and some keyValues // and return new logger contains key values as // log fields. WithCtx(ctx context.Context, args ...Field) Logger // With method set key,values and return new logger // contains this key values as log fields. With(f ...Field) Logger // Debug log debug message. Debug(msg string, args ...Field) // Info log info message. Info(msg string, args ...Field) // Message log the value as a message. // Use this to send message to some loggers that just want to get messages. // all loggers see message as info and just add simple _message tag to it. // but some other loggers just log messages (like our sentry logger). // severity of Message it just like info. Message(msg string, args ...Field) // Warn log warning message. Warn(msg string, args ...Field) // Error log error message Error(msg string, args ...Field) }
func GlobalLogger ¶
func GlobalLogger() Logger
func NewPrinterDriver ¶
NewPrinterDriver returns new instance of hexa logger with printer driver. Note: printer logger driver is just for test purpose. dont use it in production.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is an io.Writer implementation using Logger. Some packages get standard Go log.Logger as their logger. The log.Logger gets as writer as param to use for writing logs. we can use this writer as the log.Logger's writer.
Click to show internal directories.
Click to hide internal directories.