Documentation
¶
Index ¶
- func Init(level string, options ...ClientOptionFunc)
- type ClientOptionFunc
- type Logger
- func (l Logger) Debug(msg string, args ...any)
- func (l Logger) DebugContext(ctx context.Context, msg string, args ...any)
- func (l Logger) Error(msg string, args ...any)
- func (l Logger) ErrorContext(ctx context.Context, msg string, args ...any)
- func (l Logger) Fatal(msg string, args ...any)
- func (l Logger) FatalContext(ctx context.Context, msg string, args ...any)
- func (l Logger) Info(msg string, args ...any)
- func (l Logger) InfoContext(ctx context.Context, msg string, args ...any)
- func (l Logger) Warn(msg string, args ...any)
- func (l Logger) WarnContext(ctx context.Context, msg string, args ...any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(level string, options ...ClientOptionFunc)
Init custom init function that accepts the log level for the application and initializes a stdout slog logger
Types ¶
type ClientOptionFunc ¶ added in v1.0.0
type ClientOptionFunc func(*loggerOptions)
ClientOptionFunc can be used to customize a new slogs client
func WithJSONOutput ¶ added in v1.0.0
func WithJSONOutput() ClientOptionFunc
WithJSONOutput enables JSON formatted log output instead of the default text format
func WithSourceContext ¶ added in v1.0.0
func WithSourceContext(set bool) ClientOptionFunc
WithSourceContext sets the AddSource option for the slogs logger, which adds the location in the code that called the logger, to each logline
func WithWriter ¶ added in v1.0.0
func WithWriter(w io.Writer) ClientOptionFunc
WithWriter sets a given io.Writer to be the receiver for slogs logs
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a wrapper around a slog log handler
var Logr Logger
Logr is a custom text logger from the stdlib slog package
func (Logger) DebugContext ¶ added in v1.0.0
DebugContext uses the initialized logger at Debug level with a given context
func (Logger) ErrorContext ¶ added in v1.0.0
ErrorContext uses the initialized logger at Error level with a given context
func (Logger) FatalContext ¶ added in v1.0.0
FatalContext uses the initialized logger at Error level with a given context, and exits 1
func (Logger) InfoContext ¶ added in v1.0.0
InfoContext uses the initialized logger at Info level with a given context