logh

package module
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2022 License: MIT Imports: 9 Imported by: 22

README

logh

A helper to facilitate the use and configuration of the zerolog library.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// InfoEnabled - check if this level is enabled
	InfoEnabled bool

	// DebugEnabled - check if this level is enabled
	DebugEnabled bool

	// WarnEnabled - check if this level is enabled
	WarnEnabled bool

	// ErrorEnabled - check if this level is enabled
	ErrorEnabled bool

	// FatalEnabled - check if this level is enabled
	FatalEnabled bool

	// PanicEnabled - check if this level is enabled
	PanicEnabled bool

	// ErrWrongNumberOfArgs ...
	ErrWrongNumberOfArgs error = errors.New("the number of arguments must be even")
)

Functions

func ConfigureCustomLogger added in v1.0.3

func ConfigureCustomLogger(lvl Level, fmt Format, out io.Writer) *zerolog.Logger

ConfigureCustomLogger - configures the logger globally

func ConfigureGlobalLogger

func ConfigureGlobalLogger(lvl Level, fmt Format) *zerolog.Logger

ConfigureGlobalLogger - configures the logger globally

func Debug

func Debug() *zerolog.Event

Debug - returns the debug event logger if any

func Error

func Error() *zerolog.Event

Error - returns the error event logger if any

func Fatal

func Fatal() *zerolog.Event

Fatal - returns the error event logger if any

func Info

func Info() *zerolog.Event

Info - returns the info event logger if any

func Logger added in v1.0.3

func Logger() *zerolog.Logger

Logger - returns the logger itself

func Panic

func Panic() *zerolog.Event

Panic - returns the error event logger if any

func SendToStdout

func SendToStdout(output string)

SendToStdout - logs a output with no log format

func Warn

func Warn() *zerolog.Event

Warn - returns the error event logger if any

Types

type ContextualLogger

type ContextualLogger struct {
	// contains filtered or unexported fields
}

ContextualLogger - a struct containing all valid event loggers (each one can be null if not enabled)

func CreateContextualLogger

func CreateContextualLogger(keyValues ...interface{}) *ContextualLogger

CreateContextualLogger - creates loggers with context

func (*ContextualLogger) Append added in v1.0.3

func (cl *ContextualLogger) Append(keyValues ...interface{}) error

Append - appends more context

func (*ContextualLogger) CreateFromContext added in v1.0.4

func (cl *ContextualLogger) CreateFromContext(keyValues ...interface{}) (*ContextualLogger, error)

CreateFromContext - creates a new logger context from this context

func (*ContextualLogger) Debug

func (cl *ContextualLogger) Debug() *zerolog.Event

Debug - returns the event logger using the configured context

func (*ContextualLogger) Error

func (cl *ContextualLogger) Error() *zerolog.Event

Error - returns the event logger using the configured context

func (*ContextualLogger) ErrorLine added in v1.0.5

func (cl *ContextualLogger) ErrorLine() *zerolog.Event

ErrorLine - returns the event logger using the configured context

func (*ContextualLogger) ErrorLineC added in v1.0.6

func (cl *ContextualLogger) ErrorLineC(skippedStackFrames int) *zerolog.Event

ErrorLineC - returns the event logger using the configured context

func (*ContextualLogger) Fatal

func (cl *ContextualLogger) Fatal() *zerolog.Event

Fatal - returns the event logger using the configured context

func (*ContextualLogger) GetContexts added in v1.0.3

func (cl *ContextualLogger) GetContexts() []interface{}

GetContexts - returns the logger contexts

func (*ContextualLogger) Info

func (cl *ContextualLogger) Info() *zerolog.Event

Info - returns the event logger using the configured context

func (*ContextualLogger) MustAppend added in v1.0.6

func (cl *ContextualLogger) MustAppend(keyValues ...interface{})

MustAppend - appends more context, panics if any error is founbd

func (*ContextualLogger) MustCreateFromContext added in v1.0.4

func (cl *ContextualLogger) MustCreateFromContext(keyValues ...interface{}) *ContextualLogger

MustCreateFromContext - creates a new logger context from this context, raises panic if some error

func (*ContextualLogger) Panic

func (cl *ContextualLogger) Panic() *zerolog.Event

Panic - returns the event logger using the configured context

func (*ContextualLogger) Warn

func (cl *ContextualLogger) Warn() *zerolog.Event

Warn - returns the event logger using the configured context

type Format

type Format string

Format - the logger's output format

const (
	// JSON - json format
	JSON Format = "json"

	// CONSOLE - plain text format
	CONSOLE Format = "console"
)

type Level

type Level string

Level - type

const (
	// INFO - log level
	INFO Level = "info"

	// DEBUG - log level
	DEBUG Level = "debug"

	// WARN - log level
	WARN Level = "warn"

	// ERROR - log level
	ERROR Level = "error"

	// FATAL - log level
	FATAL Level = "fatal"

	// PANIC - log level
	PANIC Level = "panic"

	// NONE - log level
	NONE Level = "none"

	// SILENT - log level
	SILENT Level = "silent"
)

type StringWriter added in v1.0.6

type StringWriter struct {
	// contains filtered or unexported fields
}

StringWriter - writes in memory

func NewStringWriter added in v1.0.3

func NewStringWriter(size uint64) *StringWriter

func (*StringWriter) Bytes added in v1.0.6

func (sb *StringWriter) Bytes() []byte

Bytes - return the stored bytes

func (*StringWriter) Reset added in v1.0.6

func (sb *StringWriter) Reset()

Write - implements the io.Writer interface

func (*StringWriter) Write added in v1.0.6

func (sb *StringWriter) Write(p []byte) (n int, err error)

Write - implements the io.Writer interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL