log

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 15 Imported by: 0

README

log

bamgoo log module.

API

  • log.Info(args...) legacy flexible logging
  • log.Infof(format, args...) format logging
  • log.Infow(body, fields) structured logging

All levels support the same 3 styles:

  • Debug/Trace/Info/Notice/Warning/Error/Panic/Fatal
  • Debugf/Tracef/Infof/Noticef/Warningf/Errorf/Panicf/Fatalf
  • Debugw/Tracew/Infow/Noticew/Warningw/Errorw/Panicw/Fatalw
  • Stats()

Each log entry auto-includes identity fields in fields:

  • project
  • profile
  • node

Queue

  • async queue + batch flush
  • buffer: queue length
  • batch: flush batch size
  • timeout: flush interval
  • overflow: block (default) / drop / drop_newest / drop_oldest
  • drop: old (default) / new (works when overflow = "drop")

Documentation

Index

Constants

View Source
const (
	OverflowDrop       = "drop"
	OverflowDropNewest = "drop_newest"
	OverflowDropOldest = "drop_oldest"
	OverflowBlock      = "block"

	DropOld = "old"
	DropNew = "new"
)

Variables

This section is empty.

Functions

func Debug

func Debug(args ...Any)

func Debugf added in v0.4.0

func Debugf(format string, args ...Any)

func Debugw added in v0.4.0

func Debugw(body string, fields Map)

func Error

func Error(args ...Any)

func Errorf added in v0.4.0

func Errorf(format string, args ...Any)

func Errorw added in v0.4.0

func Errorw(body string, fields Map)

func Fatal

func Fatal(args ...Any)

func Fatalf added in v0.4.0

func Fatalf(format string, args ...Any)

func Fatalw added in v0.4.0

func Fatalw(body string, fields Map)

func Info

func Info(args ...Any)

func Infof added in v0.4.0

func Infof(format string, args ...Any)

func Infow added in v0.4.0

func Infow(body string, fields Map)

func Levels

func Levels() map[Level]string

func Notice

func Notice(args ...Any)

func Noticef added in v0.4.0

func Noticef(format string, args ...Any)

func Noticew added in v0.4.0

func Noticew(body string, fields Map)

func Panic

func Panic(args ...Any)

func Panicf added in v0.4.0

func Panicf(format string, args ...Any)

func Panicw added in v0.4.0

func Panicw(body string, fields Map)

func Stats added in v0.4.0

func Stats() Map

func Trace

func Trace(args ...Any)

func Tracef added in v0.4.0

func Tracef(format string, args ...Any)

func Tracew added in v0.4.0

func Tracew(body string, fields Map)

func Warning

func Warning(args ...Any)

func Warningf added in v0.4.0

func Warningf(format string, args ...Any)

func Warningw added in v0.4.0

func Warningw(body string, fields Map)

func Write

func Write(level Level, args ...Any)

func Writef added in v0.4.0

func Writef(level Level, format string, args ...Any)

func Writew added in v0.4.0

func Writew(level Level, body string, fields Map)

Types

type Config

type Config struct {
	Driver   string
	Level    Level
	Levels   map[Level]bool
	Sample   float64
	Json     bool
	Buffer   int
	Batch    int
	Timeout  time.Duration
	Block    bool
	Overflow string
	Drop     string
	Flag     string
	Format   string
	Setting  Map
}

type Configs

type Configs map[string]Config

type Connection added in v0.4.0

type Connection interface {
	Open() error
	Close() error
	Write(logs ...Log) error
}

type Driver

type Driver interface {
	Connect(*Instance) (Connection, error)
}

type Instance

type Instance struct {
	Name    string
	Config  Config
	Setting map[string]any
	// contains filtered or unexported fields
}

func (*Instance) Allow

func (inst *Instance) Allow(level Level, body, project, profile, node string, fields Map) bool

func (*Instance) Format

func (inst *Instance) Format(entry Log) string

type Level

type Level = int
const (
	LevelFatal Level = iota
	LevelPanic
	LevelError
	LevelWarning
	LevelNotice
	LevelInfo
	LevelTrace
	LevelDebug
)

type Log

type Log struct {
	Time    time.Time
	Level   Level
	Body    string
	Project string
	Profile string
	Node    string
	Fields  Map
}

type Module

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

func (*Module) Close

func (m *Module) Close()

func (*Module) Config

func (m *Module) Config(global Map)

func (*Module) Logging

func (m *Module) Logging(level Level, args ...Any)

func (*Module) Loggingf added in v0.4.0

func (m *Module) Loggingf(level Level, format string, args ...Any)

func (*Module) Loggingw added in v0.4.0

func (m *Module) Loggingw(level Level, body string, fields Map)

func (*Module) Open

func (m *Module) Open()

func (*Module) Register

func (m *Module) Register(name string, value Any)

func (*Module) RegisterConfig

func (m *Module) RegisterConfig(name string, cfg Config)

func (*Module) RegisterConfigs

func (m *Module) RegisterConfigs(configs Configs)

func (*Module) RegisterDriver

func (m *Module) RegisterDriver(name string, driver Driver)

func (*Module) Setup

func (m *Module) Setup()

func (*Module) Start

func (m *Module) Start()

func (*Module) Stats added in v0.4.0

func (m *Module) Stats() Map

func (*Module) Stop

func (m *Module) Stop()

func (*Module) Write

func (m *Module) Write(entry Log)

Jump to

Keyboard shortcuts

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