logger

package
v0.0.0-...-8ad27d5 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package logger provides support for initializing the log system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventFn

type EventFn func(ctx context.Context, msg string, args ...any)

EventFn is a function to be executed when configured against a log level.

type Events

type Events struct {
	Debug EventFn
	Info  EventFn
	Warn  EventFn
	Error EventFn
}

Events contains an assignment of an event function to a log level.

type Level

type Level int

Level represents a logging level.

const (
	LevelDebug Level = -4
	LevelInfo  Level = 0
	LevelWarn  Level = 4
	LevelError Level = 8
)

A set of possible logging levels.

type Logger

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

Logger represents a logger for logging information.

func New

func New(serviceName string) *Logger

New constructs a new log for application use.

func NewWithEvents

func NewWithEvents(serviceName string, events Events) *Logger

NewWithEvents constructs a new log for application use with events.

func (*Logger) Debug

func (log *Logger) Debug(ctx context.Context, msg string, args ...any)

Debug logs at LevelDebug with the given context.

func (*Logger) Debugc

func (log *Logger) Debugc(ctx context.Context, caller int, msg string, args ...any)

Debugc logs the information at the specified call stack position.

func (*Logger) Error

func (log *Logger) Error(ctx context.Context, msg string, args ...any)

Error logs at LevelError with the given context.

func (*Logger) Errorc

func (log *Logger) Errorc(ctx context.Context, caller int, msg string, args ...any)

Errorc logs the information at the specified call stack position.

func (*Logger) Info

func (log *Logger) Info(ctx context.Context, msg string, args ...any)

Info logs at LevelInfo with the given context.

func (*Logger) Infoc

func (log *Logger) Infoc(ctx context.Context, caller int, msg string, args ...any)

Infoc logs the information at the specified call stack position.

func (*Logger) Warn

func (log *Logger) Warn(ctx context.Context, msg string, args ...any)

Warn logs at LevelWarn with the given context.

func (*Logger) Warnc

func (log *Logger) Warnc(ctx context.Context, caller int, msg string, args ...any)

Warnc logs the information at the specified call stack position.

Jump to

Keyboard shortcuts

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