Documentation
¶
Index ¶
- Constants
- func Debug(ctx context.Context, msg string, fields ...any)
- func DebugWithTrace(ctx context.Context, msg, trace string, fields ...any)
- func Error(ctx context.Context, err error, msg string, fields ...any)
- func Fatal(ctx context.Context, msg string, fields ...any)
- func Force(ctx context.Context, msg string, fields ...any)
- func Info(ctx context.Context, msg string, fields ...any)
- func Init(level Level, opts ...Option)
- func InjectFields(ctx context.Context, fields ...any) context.Context
- func NewGrpcLogger(level Level, opts ...GrpcOption) grpclog.LoggerV2
- func NewRsyslogWriter(level Level, network, raddr, identifier string) (io.Writer, error)
- func NewSyslogWriter(level Level, identifier string) (io.Writer, error)
- func SetCallerEnabled(enabled bool)
- func SetDeduplicationEnabled(enabled bool)
- func SetGlobalLevel(level Level)
- func ToContext(ctx context.Context, logger *Logger) context.Context
- func Warn(ctx context.Context, msg string, fields ...any)
- type Fields
- type GrpcOption
- type Level
- type Logger
- func (l *Logger) Debug(ctx context.Context, msg string, fields ...any)
- func (l *Logger) DebugWithTrace(ctx context.Context, msg, trace string, fields ...any)
- func (l *Logger) Error(ctx context.Context, err error, msg string, fields ...any)
- func (l *Logger) Fatal(ctx context.Context, msg string, fields ...any)
- func (l *Logger) Force(ctx context.Context, msg string, fields ...any)
- func (l *Logger) GetLevel() Level
- func (l *Logger) Info(ctx context.Context, msg string, fields ...any)
- func (l *Logger) Level(level Level) *Logger
- func (l *Logger) Warn(ctx context.Context, msg string, fields ...any)
- type Option
Constants ¶
const ( TraceLevel = Level(zerolog.TraceLevel) DebugLevel = Level(zerolog.DebugLevel) InfoLevel = Level(zerolog.InfoLevel) WarnLevel = Level(zerolog.WarnLevel) ErrorLevel = Level(zerolog.ErrorLevel) FatalLevel = Level(zerolog.FatalLevel) )
Variables ¶
This section is empty.
Functions ¶
func NewGrpcLogger ¶
func NewGrpcLogger(level Level, opts ...GrpcOption) grpclog.LoggerV2
func NewRsyslogWriter ¶
func SetCallerEnabled ¶
func SetCallerEnabled(enabled bool)
SetCallerEnabled sets the global flag that determines whether to add in information about the log point ("file:line") in the log entry.
func SetDeduplicationEnabled ¶
func SetDeduplicationEnabled(enabled bool)
SetDeduplicationEnabled sets the global flag that determines whether to uniqualize custom fields keys.
Must be called before using of the custom fields.
func SetGlobalLevel ¶
func SetGlobalLevel(level Level)
SetGlobalLevel creates a logger with specified level and stores it as default logger.
Types ¶
type GrpcOption ¶
type GrpcOption func(*grpcLogger)
func WithGrpcOutput ¶
func WithGrpcOutput(w io.Writer) GrpcOption
func WithGrpcPlainText ¶
func WithGrpcPlainText(withTimestamp bool, w ...io.Writer) GrpcOption
WithGrpcPlainText creates an output writer with the plain text format instead of JSON.
Optionally the inner output writer could be specified as second argument. Otherwise, the os.Stdout will be used.
func WithGrpcTimestamp ¶
func WithGrpcTimestamp() GrpcOption
type Level ¶
type Level int8
func ParseLevel ¶
ParseLevel returns Level according specified value (case-insensitive).
If invalid value specified, then an error returned with default level (ErrorLevel).
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func FromContext ¶
func (*Logger) DebugWithTrace ¶
type Option ¶
type Option func(*Logger)
func WithOutput ¶
func WithPlainText ¶
WithPlainText creates an output writer with the plain text format instead of JSON.
Optionally the inner output writer could be specified as second argument. Otherwise, the os.Stdout will be used.
func WithTimestamp ¶
func WithTimestamp() Option