Documentation ¶
Overview ¶
Package log implements logging.
Index ¶
- func Debug(ctx context.Context, msg string, args ...any)
- func Debugf(ctx context.Context, format string, args ...any)
- func Error(ctx context.Context, msg string, err error, args ...any)
- func Errorf(ctx context.Context, err error, format string, args ...any)
- func FromContext(ctx context.Context) *slog.Logger
- func Info(ctx context.Context, msg string, args ...any)
- func Infof(ctx context.Context, format string, args ...any)
- func Logf(ctx context.Context, level slog.Level, format string, args ...any)
- func NewContext(ctx context.Context, l *slog.Logger) context.Context
- func NewGoogleCloudHandler() slog.Handler
- func Warn(ctx context.Context, msg string, args ...any)
- func Warnf(ctx context.Context, format string, args ...any)
- type LineHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶
FromContext retrieves a logger from the context. If there is none, it returns the default logger.
func NewContext ¶
NewContext adds the logger to the context.
func NewGoogleCloudHandler ¶
NewGoogleCloudHandler returns a Handler that outputs JSON for the Google Cloud logging service. See https://cloud.google.com/logging/docs/agent/logging/configuration#special-fields for treatment of special fields.
Types ¶
type LineHandler ¶
type LineHandler struct {
// contains filtered or unexported fields
}
LineHandler is a slog.Handler that writes log events one per line in an easy-to-read format:
time level message label1=value1 label2=value2 ...
func NewLineHandler ¶
func NewLineHandler(w io.Writer) *LineHandler
Click to show internal directories.
Click to hide internal directories.