log

package module
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 14 Imported by: 8

README

go-log

Documentation

Index

Constants

View Source
const ContextKeyLogFields logContextType = "nrfta/go-log/Fields"

ContextKeyLogFields is the key for the logging fields context value.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

func DebugWithFields

func DebugWithFields(fields Fields, args ...interface{})

func DebugWithFieldsf added in v0.3.0

func DebugWithFieldsf(fields Fields, message string, args ...interface{})

func Debugf

func Debugf(message string, args ...interface{})

func Error

func Error(args ...interface{})

func ErrorWithFields

func ErrorWithFields(fields Fields, args ...interface{})

func ErrorWithFieldsf added in v0.3.0

func ErrorWithFieldsf(fields Fields, message string, args ...interface{})

func Errorf

func Errorf(message string, args ...interface{})

func Fatal

func Fatal(args ...interface{})

func FatalWithFields

func FatalWithFields(fields Fields, args ...interface{})

func FatalWithFieldsf added in v0.3.0

func FatalWithFieldsf(fields Fields, message string, args ...interface{})

func Fatalf

func Fatalf(message string, args ...interface{})

func Info

func Info(args ...interface{})

func InfoWithFields

func InfoWithFields(fields Fields, args ...interface{})

func InfoWithFieldsf added in v0.3.0

func InfoWithFieldsf(fields Fields, message string, args ...interface{})

func Infof

func Infof(message string, args ...interface{})

func New

func New(isJSONFormatted bool, logLevel string) *logrus.Logger

New - Creates a new instance of logrus with customized configuration

func NewError added in v0.9.0

func NewError(args ...interface{}) error

func NewErrorWithFields added in v0.9.0

func NewErrorWithFields(fields Fields, args ...interface{}) error

func NewErrorWithFieldsf added in v0.9.0

func NewErrorWithFieldsf(fields Fields, message string, args ...interface{}) error

func NewErrorf added in v0.9.0

func NewErrorf(message string, args ...interface{}) error

func NewSLogChiMiddleware added in v0.11.0

func NewSLogChiMiddleware(l *slog.Logger) func(http.Handler) http.Handler

NewSLogChiMiddleware is used to log http request information. It takes a pointer to an slog.Logger to use. If `l` is nil, it uses the default logger

func NewSLogGraphQLResponseMiddleware added in v0.12.0

func NewSLogGraphQLResponseMiddleware(l *slog.Logger, s VariablesScrubber) graphql.ResponseMiddleware

NewSLogGraphQLResponseMiddleware is used to log GraphQL requests and responses.

func Panic

func Panic(args ...interface{})

func PanicWithFields

func PanicWithFields(fields Fields, args ...interface{})

func PanicWithFieldsf added in v0.3.0

func PanicWithFieldsf(fields Fields, message string, args ...interface{})

func Panicf

func Panicf(message string, args ...interface{})

func PopContextFields added in v0.7.0

func PopContextFields(ctx context.Context)

PopContextFields pops the last entry off of the logging fields stack.

func PushContextFields added in v0.7.0

func PushContextFields(ctx context.Context, fields ...Field)

PushContextFields pushes the given fields onto the logging fields stack.

func ServerLogger

func ServerLogger() func(next http.Handler) http.Handler

ServerLogger is a middleware that logs the start and end of each request, along with some useful data about what was requested, what the response status was, and how long it took to return.

func Warn

func Warn(args ...interface{})

func WarnWithFields

func WarnWithFields(fields Fields, args ...interface{})

func WarnWithFieldsf added in v0.3.0

func WarnWithFieldsf(fields Fields, message string, args ...interface{})

func Warnf

func Warnf(message string, args ...interface{})

func WithContext added in v0.7.0

func WithContext(parent context.Context, fields ...Field) context.Context

WithContext initializes context with a logging fields stack with the given fields. If the given context has already bene initialized, then the fields are pushed onto the existing stack.

func Writer

func Writer() *io.PipeWriter

func WriterLevel added in v0.5.0

func WriterLevel(logLevel string) *io.PipeWriter

Types

type ByteLogs added in v0.10.0

type ByteLogs struct {
	Log    *bytes.Buffer
	Parsed []map[string]interface{}
}

func (*ByteLogs) CheckForLogEndMessage added in v0.10.0

func (b *ByteLogs) CheckForLogEndMessage(customEnd ...string) bool

func (*ByteLogs) LogInLogs added in v0.10.0

func (b *ByteLogs) LogInLogs(key string, value interface{}) bool

func (*ByteLogs) Parse added in v0.10.0

func (b *ByteLogs) Parse(log *bytes.Buffer)

type Field added in v0.7.0

type Field struct {
	Name  string
	Value interface{}
}

Field represents a logging field.

func FieldsToFieldsArray added in v0.9.0

func FieldsToFieldsArray(fields Fields) (arr []Field)

func MakeField added in v0.7.0

func MakeField(name string, value interface{}) Field

MakeField creates a new logging field.

type Fields

type Fields map[string]interface{}

Fields Type to pass when we want to call WithFields for structured logging

func GetContextFields added in v0.7.0

func GetContextFields(ctx context.Context, additionalFields ...Field) Fields

GetContextFields retrieves the logging `Fields` from context. GetContextFields returns an empty Fields map if the context has not been initialized by calling WithContext.

type Logger

type Logger interface {
	Info(args ...interface{})
	Infof(message string, args ...interface{})
	Debug(args ...interface{})
	Debugf(message string, args ...interface{})
	Error(args ...interface{})
	Errorf(message string, args ...interface{})
	Warn(args ...interface{})
	Warnf(message string, args ...interface{})
	Fatal(args ...interface{})
	Fatalf(message string, args ...interface{})
	Panic(args ...interface{})
	Panicf(message string, args ...interface{})
	Writer() *io.PipeWriter
}

Logger interface

func GetLogger added in v0.6.0

func GetLogger() Logger

func RequestLogger

func RequestLogger(ctx context.Context) Logger

RequestLogger creates a logger with the request ID on it

type PrefixedLogger added in v0.10.0

type PrefixedLogger struct {
	Prefix         string
	LoggerInstance *logrus.Logger
}

func NewPrefixedLogger added in v0.10.0

func NewPrefixedLogger(prefix string, instance Logger) PrefixedLogger

func (*PrefixedLogger) Debug added in v0.10.0

func (l *PrefixedLogger) Debug(args ...interface{})

func (*PrefixedLogger) DebugWithFields added in v0.10.0

func (l *PrefixedLogger) DebugWithFields(fields Fields, args ...interface{})

func (*PrefixedLogger) DebugWithFieldsf added in v0.10.0

func (l *PrefixedLogger) DebugWithFieldsf(fields Fields, message string, args ...interface{})

func (*PrefixedLogger) Debugf added in v0.10.0

func (l *PrefixedLogger) Debugf(message string, args ...interface{})

func (*PrefixedLogger) Error added in v0.10.0

func (l *PrefixedLogger) Error(args ...interface{})

func (*PrefixedLogger) ErrorWithFields added in v0.10.0

func (l *PrefixedLogger) ErrorWithFields(fields Fields, args ...interface{})

func (*PrefixedLogger) ErrorWithFieldsf added in v0.10.0

func (l *PrefixedLogger) ErrorWithFieldsf(fields Fields, message string, args ...interface{})

func (*PrefixedLogger) Errorf added in v0.10.0

func (l *PrefixedLogger) Errorf(message string, args ...interface{})

func (*PrefixedLogger) Fatal added in v0.10.0

func (l *PrefixedLogger) Fatal(args ...interface{})

func (*PrefixedLogger) FatalWithFields added in v0.10.0

func (l *PrefixedLogger) FatalWithFields(fields Fields, args ...interface{})

func (*PrefixedLogger) FatalWithFieldsf added in v0.10.0

func (l *PrefixedLogger) FatalWithFieldsf(fields Fields, message string, args ...interface{})

func (*PrefixedLogger) Fatalf added in v0.10.0

func (l *PrefixedLogger) Fatalf(message string, args ...interface{})

func (*PrefixedLogger) Info added in v0.10.0

func (l *PrefixedLogger) Info(args ...interface{})

implement logger interface

func (*PrefixedLogger) InfoWithFields added in v0.10.0

func (l *PrefixedLogger) InfoWithFields(fields Fields, args ...interface{})

func (*PrefixedLogger) InfoWithFieldsf added in v0.10.0

func (l *PrefixedLogger) InfoWithFieldsf(fields Fields, message string, args ...interface{})

func (*PrefixedLogger) Infof added in v0.10.0

func (l *PrefixedLogger) Infof(message string, args ...interface{})

func (*PrefixedLogger) Panic added in v0.10.0

func (l *PrefixedLogger) Panic(args ...interface{})

func (*PrefixedLogger) PanicWithFields added in v0.10.0

func (l *PrefixedLogger) PanicWithFields(fields Fields, args ...interface{})

func (*PrefixedLogger) PanicWithFieldsf added in v0.10.0

func (l *PrefixedLogger) PanicWithFieldsf(fields Fields, message string, args ...interface{})

func (*PrefixedLogger) Panicf added in v0.10.0

func (l *PrefixedLogger) Panicf(message string, args ...interface{})

func (*PrefixedLogger) PrefixError added in v0.10.0

func (l *PrefixedLogger) PrefixError(err error, msg string) error

func (*PrefixedLogger) Warn added in v0.10.0

func (l *PrefixedLogger) Warn(args ...interface{})

func (*PrefixedLogger) WarnWithFields added in v0.10.0

func (l *PrefixedLogger) WarnWithFields(fields Fields, args ...interface{})

func (*PrefixedLogger) WarnWithFieldsf added in v0.10.0

func (l *PrefixedLogger) WarnWithFieldsf(fields Fields, message string, args ...interface{})

func (*PrefixedLogger) Warnf added in v0.10.0

func (l *PrefixedLogger) Warnf(message string, args ...interface{})

func (*PrefixedLogger) WrapError added in v0.10.0

func (l *PrefixedLogger) WrapError(err error) error

func (*PrefixedLogger) Writer added in v0.10.0

func (l *PrefixedLogger) Writer() *io.PipeWriter

type VariablesScrubber added in v0.12.0

type VariablesScrubber interface {
	Scrub(map[string]any) map[string]any
}

Jump to

Keyboard shortcuts

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