log

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2025 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LevelDefault means the log entry has no assigned severity level.
	LevelDefault = Level(0)
	// LevelDebug means debug or trace information.
	LevelDebug = Level(100)
	// LevelInfo means routine information, such as ongoing status or performance.
	LevelInfo = Level(200)
	// LevelNotice means normal but significant events, such as start up, shut down, or configuration.
	LevelNotice = Level(300)
	// LevelWarning means events that might cause problems.
	LevelWarning = Level(400)
	// LevelError means events that are likely to cause problems.
	LevelError = Level(500)
	// LevelCritical means events that cause more severe problems or brief outages.
	LevelCritical = Level(600)
	// LevelAlert means a person must take an action immediately.
	LevelAlert = Level(700)
	// LevelEmergency means one or more systems are unusable.
	LevelEmergency = Level(800)
)

Variables

This section is empty.

Functions

func Alert

func Alert(msg string, args ...any)

func Critical

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

func Debug

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

func Emergency

func Emergency(msg string, args ...any)

func Error

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

func Info

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

func Notice

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

func Print

func Print(msg string, args ...any)

func SetDefaultLogger

func SetDefaultLogger(config Config)

func Warning

func Warning(msg string, args ...any)

Types

type Config

type Config struct {
	Name         string
	Level        Level
	Formatter    Formatter
	Writer       Writer
	PanicOnError bool
}

func (Config) String

func (config Config) String() string

type Entry

type Entry struct {
	Message   string `json:"message"`
	Severity  string `json:"severity,omitempty"`
	Trace     string `json:"logging.googleapis.com/trace,omitempty"`
	Component string `json:"component,omitempty"`
}

func (*Entry) String

func (entry *Entry) String() string

type Event

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

func NewEvent

func NewEvent(level Level, msg string, args ...any) *Event

func (*Event) CreatedAt

func (event *Event) CreatedAt() time.Time

func (*Event) DeleteLabel

func (event *Event) DeleteLabel(key string)

func (*Event) Done

func (event *Event) Done()

func (*Event) Label

func (event *Event) Label(key, value string)

func (*Event) Labels

func (event *Event) Labels(fn func(key, value string))

func (*Event) Level

func (event *Event) Level() Level

func (*Event) Message

func (event *Event) Message() string

func (*Event) Name

func (event *Event) Name() string

func (*Event) String

func (event *Event) String() string

type Formatter

type Formatter interface {
	Format(event *Event) (string, error)
}

func GoogleCloudFormatter

func GoogleCloudFormatter() Formatter

func SimpleFormatter

func SimpleFormatter() Formatter

type Level

type Level int

func ParseLevel

func ParseLevel(s string) Level

func (Level) String

func (level Level) String() string

String converts a severity level to a string.

type Logger

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

func NewLogger

func NewLogger(config Config) *Logger

func (*Logger) Alert

func (logger *Logger) Alert(msg string, args ...any) *Event

func (*Logger) Critical

func (logger *Logger) Critical(msg string, args ...any) *Event

func (*Logger) Debug

func (logger *Logger) Debug(msg string, args ...any) *Event

func (*Logger) Emergency

func (logger *Logger) Emergency(msg string, args ...any) *Event

func (*Logger) Error

func (logger *Logger) Error(msg string, args ...any) *Event

func (*Logger) Event

func (logger *Logger) Event(level Level, msg string, args ...any) *Event

func (*Logger) Flush

func (logger *Logger) Flush(event *Event)

func (*Logger) Info

func (logger *Logger) Info(msg string, args ...any) *Event

func (*Logger) Level

func (logger *Logger) Level() Level

func (*Logger) Notice

func (logger *Logger) Notice(msg string, args ...any) *Event

func (*Logger) Print

func (logger *Logger) Print(msg string, args ...any) *Event

func (*Logger) String

func (logger *Logger) String() string

func (*Logger) Warning

func (logger *Logger) Warning(msg string, args ...any) *Event

type Writer

type Writer interface {
	Write(message string) error
}

func ConsoleWriter

func ConsoleWriter() Writer

Jump to

Keyboard shortcuts

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