logging

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2024 License: AGPL-3.0 Imports: 6 Imported by: 6

Documentation

Overview

Package logging provides a logging implementation for use with vise.

Index

Constants

View Source
const (
	// No logging
	LVL_NONE = iota
	// Error log level - unexpected states that need immediate developer attention.
	LVL_ERROR
	// Warning log level - unexpected states that may need developer attention.
	LVL_WARN
	// Info log level - expected states that are of general interest to the end-user.
	LVL_INFO
	// Debug log level - expected states that are of general interest to the developer.
	LVL_DEBUG
	// Trace log level - everything else.
	LVL_TRACE
)

Variables

View Source
var (
	LogLevel = LVL_NONE
)
View Source
var (
	// LogWriter is used as io.Writer the Vanilla Logger implementation.
	LogWriter = os.Stderr
)

Functions

func AsString

func AsString(level int) string

AsString returns the string representation used in logging output for the given log level.

Types

type Logger

type Logger interface {
	// Writef logs a line to the given writer with the given loglevel.
	Writef(w io.Writer, level int, msg string, args ...any)
	// WriteCtxf logs a line with context to the given writer with the given loglevel.
	WriteCtxf(ctx context.Context, w io.Writer, level int, msg string, args ...any)
	// Printf logs a line to the default writer with the given loglevel.
	Printf(level int, msg string, args ...any)
	// Printf logs a line with context to the default writer with the given loglevel.
	PrintCtxf(ctx context.Context, level int, msg string, args ...any)
	// Tracef logs a line to the default writer the TRACE loglevel.
	Tracef(msg string, args ...any)
	// TraceCtxf logs a line with context to the default writer the TRACE loglevel.
	TraceCtxf(ctx context.Context, msg string, args ...any)
	// Debugf logs a line to the default writer the DEBUG loglevel.
	Debugf(msg string, args ...any)
	// DebugCtxf logs a line with context to the default writer the DEBUG loglevel.
	DebugCtxf(ctx context.Context, msg string, args ...any)
	// Infof logs a line to the default writer the INFO loglevel.
	Infof(msg string, args ...any)
	// InfoCtxf logs a line with context to the default writer the INFO loglevel.
	InfoCtxf(ctx context.Context, msg string, args ...any)
	// Warnf logs a line to the default writer the WARN loglevel.
	Warnf(msg string, args ...any)
	// WarnCtxf logs a line with context to the default writer the WARN loglevel.
	WarnCtxf(ctx context.Context, msg string, args ...any)
	// Errorf logs a line to the default writer the ERROR loglevel.
	Errorf(msg string, args ...any)
	// ErrorCtxf logs a line with context to the default writer the ERROR loglevel.
	ErrorCtxf(ctx context.Context, msg string, args ...any)
}

type Vanilla

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

Vanilla is a basic single-line structured output logger for terminal output.

func NewVanilla

func NewVanilla() Vanilla

NewVanilla creates a new Vanilla logger.

func (Vanilla) DebugCtxf

func (v Vanilla) DebugCtxf(ctx context.Context, msg string, args ...any)

DebugCtxf logs a line with context with level DEBUG to the global writer.

func (Vanilla) Debugf

func (v Vanilla) Debugf(msg string, args ...any)

Debugf logs a line with level DEBUG to the global writer.

func (Vanilla) ErrorCtxf

func (v Vanilla) ErrorCtxf(ctx context.Context, msg string, args ...any)

ErrorCtxf logs a line with context with level ERROR to the global writer.

func (Vanilla) Errorf

func (v Vanilla) Errorf(msg string, args ...any)

Errorf logs a line with level ERROR to the global writer.

func (Vanilla) InfoCtxf

func (v Vanilla) InfoCtxf(ctx context.Context, msg string, args ...any)

InfoCtxf logs a line with context with level INFO to the global writer.

func (Vanilla) Infof

func (v Vanilla) Infof(msg string, args ...any)

Infof logs a line with level INFO to the global writer.

func (Vanilla) PrintCtxf

func (v Vanilla) PrintCtxf(ctx context.Context, level int, msg string, args ...any)

PrintCtxf logs with context to the global writer.

func (Vanilla) Printf

func (v Vanilla) Printf(level int, msg string, args ...any)

Printf logs to the global writer.

func (Vanilla) TraceCtxf

func (v Vanilla) TraceCtxf(ctx context.Context, msg string, args ...any)

TraceCtxf logs a line with context with level TRACE to the global writer.

func (Vanilla) Tracef

func (v Vanilla) Tracef(msg string, args ...any)

Tracef logs a line with level TRACE to the global writer.

func (Vanilla) WarnCtxf

func (v Vanilla) WarnCtxf(ctx context.Context, msg string, args ...any)

WarnCtxf logs a line with context with level WARN to the global writer.

func (Vanilla) Warnf

func (v Vanilla) Warnf(msg string, args ...any)

Warnf logs a line with level WARN to the global writer.

func (Vanilla) WithDomain

func (v Vanilla) WithDomain(domain string) Vanilla

WithDomain sets the logging domain. It is prepended to the caller file/line information.

func (Vanilla) WithLevel

func (v Vanilla) WithLevel(level int) Vanilla

WithLevel overrides the globally set loglevel for the logger instance.

func (Vanilla) WriteCtxf

func (v Vanilla) WriteCtxf(ctx context.Context, w io.Writer, level int, msg string, args ...any)

WriteCtxf logs with context to the given writer.

func (Vanilla) Writef

func (v Vanilla) Writef(w io.Writer, level int, msg string, args ...any)

Writef logs to the given writer.

Jump to

Keyboard shortcuts

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