logger

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestContextKey string = "RequestContext"
)

Variables

This section is empty.

Functions

func AddMiddleLayers

func AddMiddleLayers(middlelayers ...MiddleLayer)

func Debug

func Debug(ctx context.Context, format string, a ...any)

func Error

func Error(ctx context.Context, format string, a ...any)

func Fatal

func Fatal(ctx context.Context, format string, a ...any)

func Info

func Info(ctx context.Context, format string, a ...any)

func Infof

func Infof(ctx context.Context, format string, fields *Fields)

func Infow

func Infow(ctx context.Context, message string, fs *Fields)

func Panic

func Panic(ctx context.Context, format string, a ...any)

func Warn

func Warn(ctx context.Context, format string, a ...any)

Types

type Config

type Config struct {
	AppName string
	Build   string
	Level   LogLevel
}

Build : if prod it will set to prod else dev

func (Config) InitiateLogger

func (c Config) InitiateLogger() error

type Fields

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

func RequestMiddleLayer

func RequestMiddleLayer(ctx context.Context, msg string, fields *Fields) (context.Context, string, *Fields)

func (*Fields) AddField

func (f *Fields) AddField(key string, value any)

type LogLevel

type LogLevel string
const (
	DebugLevel LogLevel = "debug"

	// InfoLevel is the default logging priority.
	InfoLevel LogLevel = "info"

	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel LogLevel = "warn"

	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-level logs.
	ErrorLevel LogLevel = "error"

	// DPanicLevel logs are particularly important errors. In development the
	// logger panics after writing the message.
	PanicLevel LogLevel = "panic"

	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel LogLevel = "fatal"
)

type MiddleLayer

type MiddleLayer func(ctx context.Context, msg string, fields *Fields) (context.Context, string, *Fields)

type RequestContext

type RequestContext struct {
	SessionID     string
	RequestID     string
	ClientAppID   string
	UserID        string
	TransactionID string
	Method        string
	URI           string
	APIStartTime  time.Time
	IP            string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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