logger

package
v0.0.0-...-113aa42 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogData

type LogData map[string]interface{}

Metadata associated with a logger and passed to log events

type LogEvent

type LogEvent struct {
	// Log levels:
	// - debug
	// - info
	// - warn
	// - error
	Level string

	// Identifies the type of event with a unique name
	Name string

	// Metadata available to the log event
	Data LogData
}

LogEvent is created for each log that occurs and explains details about the log message.

func (*LogEvent) DataToBool

func (l *LogEvent) DataToBool(key string) bool

DataToBool safely returns the Data[key] value as a bool

func (*LogEvent) DataToInt

func (l *LogEvent) DataToInt(key string) int

DataToBool safely returns the Data[key] value as a bool

func (*LogEvent) DataToString

func (l *LogEvent) DataToString(key string) string

DataToString safely returns the Data[key] value as a string

func (*LogEvent) DataToStringSlice

func (l *LogEvent) DataToStringSlice(key string) []string

DataToString safely returns the Data[key] value as a string

type Logger

type Logger struct {
	// Public metadata that is attached to each log event
	Data LogData
	// contains filtered or unexported fields
}

Logger allows you to log events that another package can subscribe to and act upon. TODO - Can Logger be private requiring `logger.New` to be used? How do we pass instances of `logger` when private?

func New

func New(onEvent eventFunc) *Logger

Logger constructor that binds to an error, success, and event handler

func (*Logger) Debug

func (l *Logger) Debug(code string)

Debug log helper method

func (*Logger) Info

func (l *Logger) Info(code string)

Info log helper method

func (*Logger) Log

func (l *Logger) Log(level string, name string)

Log event with a log level and log event name

func (*Logger) SuccessEvent

func (l *Logger) SuccessEvent() *LogEvent

Success return an event with the name "success"

func (*Logger) Warn

func (l *Logger) Warn(code string)

Warn log helper method

Jump to

Keyboard shortcuts

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