logger

package
v1.15.12 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package logger is a package that provides a logger interface and an adapter for the slog package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

func NewAdapter

func NewAdapter(out io.Writer, level slog.Level, traceKey interface{}) *Adapter

func (*Adapter) Debug

func (l *Adapter) Debug(entry logjuice.GoogleLogEntry)

Debug logs a debug message.

func (*Adapter) Error

func (l *Adapter) Error(entry logjuice.GoogleLogEntry)

Error logs an error message.

func (*Adapter) Info

func (l *Adapter) Info(entry logjuice.GoogleLogEntry)

Info logs an info message.

func (*Adapter) JSONLog added in v1.14.6

func (l *Adapter) JSONLog(ctx context.Context, level logjuice.LogLevel, data interface{}, emoji string, message ...string)

JSONLog logs a structured message with the specified level, emoji & messages, in a structured way following Google Cloud's logging guidelines.

The data parameter is expected to be a struct or map that can be marshaled into JSON.

Message field will be populated with the indent JSON string of the data.

If the data is nil, the message field will be populated with a message indicating that the data is nil.

If the data cannot be indented into a JSON string, the message field will be populated with a message indicating that the data could not be indented.

Trace is retrieved from the context using the logger's trace key.

func (*Adapter) Log added in v1.14.6

func (l *Adapter) Log(ctx context.Context, level logjuice.LogLevel, message, component string)

Log logs a message.

func (*Adapter) SLog added in v1.14.6

func (l *Adapter) SLog(ctx context.Context, level logjuice.LogLevel, emoji string, message ...string)

SLog logs a structured message with the specified level, emoji & messages, in a structured way following Google Cloud's logging guidelines.

Trace is retrieved from the context using the logger's trace key.

func (*Adapter) Warn

func (l *Adapter) Warn(entry logjuice.GoogleLogEntry)

Warn logs a warning message.

Jump to

Keyboard shortcuts

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