log

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: MIT Imports: 6 Imported by: 3

README

pkg/log

Simple logging package based on log/slog.

Environment Variables

Name Description Default Required
LOG_FORMAT Log format (gcp, json, text) text
SERVICE Service name. use for gcp log label.
ENV Environment. use for gcp log label.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Fstring is alias for slog.String
	Fstring = slog.String
	// Fint is alias for slog.Int
	Fint = slog.Int
	// Fuint is alias for slog.Uint
	Fint64 = slog.Int64
	// Fuint64 is alias for slog.Uint64
	Fuint64 = slog.Uint64
	// Ffloat32 is alias for slog.Float32
	Ffloat64 = slog.Float64
	// Ffloat64 is alias for slog.Float64
	Fbool = slog.Bool
	// Ftime is alias for slog.Time
	Ftime = slog.Time
	// Fduration is alias for slog.Duration
	Fduration = slog.Duration
	// Fany is alias for slog.Any
	Fany = slog.Any
	// With is alias for slog.With
	With = slog.With
)
View Source
var (
	SeverityDefault  = slog.Level(logging.Default)
	SeverityDebug    = slog.Level(logging.Debug)
	SeverityInfo     = slog.Level(logging.Info)
	SeverityNotice   = slog.Level(logging.Notice)
	SeverityWarning  = slog.Level(logging.Warning)
	SeverityError    = slog.Level(logging.Error)
	SeverityCritical = slog.Level(logging.Critical)
)

Functions

func Critical

func Critical(msg string, attrs ...any)

Critical logs a critical message.

func CriticalContext added in v0.0.6

func CriticalContext(ctx context.Context, msg string, attrs ...any)

CriticalContext logs a critical message with a context.

func Debug

func Debug(msg string, attrs ...any)

Debug logs a debug message.

func DebugContext added in v0.0.6

func DebugContext(ctx context.Context, msg string, attrs ...any)

DebugContext logs a debug message with a context.

func Error

func Error(msg string, attrs ...any)

Error logs an error message.

func ErrorContext added in v0.0.6

func ErrorContext(ctx context.Context, msg string, attrs ...any)

ErrorContext logs an error message with a context.

func Fatal added in v0.0.6

func Fatal(msg string, attrs ...any)

Fatal logs a critical message and exits.

func FatalContext added in v0.0.6

func FatalContext(ctx context.Context, msg string, attrs ...any)

FatalContext logs a critical message with a context and exits.

func Ferror added in v0.0.4

func Ferror(err error) slog.Attr

Ferror is return error attribute

func Info

func Info(msg string, attrs ...any)

Info logs an info message.

func InfoContext added in v0.0.6

func InfoContext(ctx context.Context, msg string, attrs ...any)

InfoContext logs an info message with a context.

func Notice

func Notice(msg string, attrs ...any)

Notice logs a notice message.

func NoticeContext added in v0.0.6

func NoticeContext(ctx context.Context, msg string, attrs ...any)

NoticeContext logs a notice message with a context.

func Panic

func Panic(msg string, attrs ...any)

Panic logs a critical message and panics.

func PanicContext added in v0.0.6

func PanicContext(ctx context.Context, msg string, attrs ...any)

PanicContext logs a critical message with a context and panics.

func Warn

func Warn(msg string, attrs ...any)

Warn logs a warning message.

func WarnContext added in v0.0.6

func WarnContext(ctx context.Context, msg string, attrs ...any)

WarnContext logs a warning message with a context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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