log

package module
v0.0.0-...-8dbc414 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2022 License: ISC Imports: 12 Imported by: 5

README

The github.com/exograd/go-log package is now part of go-daemon as github.com/exograd/go-daemon/dlog.

Project

This repository contains a Go library providing a logger with support for log entry data and logger inheritance.

Contact

If you find a bug or have any question, feel free to open a GitHub issue.

Please note that we do not currently review or accept any contribution.

Documentation

Index

Constants

View Source
const (
	BOM          = string('\uFEFF')
	FacilityCode = 16 // local use 0
)

Variables

View Source
var (
	ColorBlack   = Color(0)
	ColorRed     = Color(1)
	ColorGreen   = Color(2)
	ColorYellow  = Color(3)
	ColorBlue    = Color(4)
	ColorMagenta = Color(5)
	ColorCyan    = Color(6)
	ColorWhite   = Color(7)
)

Functions

func Colorize

func Colorize(color Color, text string) string

Types

type Backend

type Backend interface {
	Log(Message)
}

type BackendType

type BackendType string
const (
	BackendTypeTerminal BackendType = "terminal"
	BackendTypeSyslog   BackendType = "syslog"
)

type Color

type Color int

type Data

type Data map[string]Datum

func MergeData

func MergeData(dataList ...Data) Data

type Datum

type Datum interface{}

type Level

type Level string
const (
	LevelDebug Level = "debug"
	LevelInfo  Level = "info"
	LevelError Level = "error"
)

type Logger

type Logger struct {
	Cfg        LoggerCfg
	Backend    Backend
	Domain     string
	Data       Data
	DebugLevel int
}

func DefaultLogger

func DefaultLogger(name string) *Logger

func NewLogger

func NewLogger(name string, cfg LoggerCfg) (*Logger, error)

func (*Logger) Child

func (l *Logger) Child(domain string, data Data) *Logger

func (*Logger) Debug

func (l *Logger) Debug(level int, format string, args ...interface{})

func (*Logger) DebugData

func (l *Logger) DebugData(data Data, level int, format string, args ...interface{})

func (*Logger) Error

func (l *Logger) Error(format string, args ...interface{})

func (*Logger) ErrorData

func (l *Logger) ErrorData(data Data, format string, args ...interface{})

func (*Logger) Info

func (l *Logger) Info(format string, args ...interface{})

func (*Logger) InfoData

func (l *Logger) InfoData(data Data, format string, args ...interface{})

func (*Logger) Log

func (l *Logger) Log(msg Message)

func (*Logger) StdLogger

func (l *Logger) StdLogger(level Level) *stdlog.Logger

func (*Logger) Write

func (l *Logger) Write(data []byte) (int, error)

type LoggerCfg

type LoggerCfg struct {
	BackendType BackendType      `json:"backend_type"`
	BackendData *json.RawMessage `json:"backend,omitempty"`
	Backend     interface{}      `json:"-"`
	DebugLevel  int              `json:"debug_level"`
}

type Message

type Message struct {
	Time       *time.Time
	Level      Level
	DebugLevel int
	Message    string
	Data       Data
	// contains filtered or unexported fields
}

type SyslogBackend

type SyslogBackend struct {
	Cfg SyslogBackendCfg
	// contains filtered or unexported fields
}

func NewSyslogBackend

func NewSyslogBackend(cfg SyslogBackendCfg) (*SyslogBackend, error)

func (*SyslogBackend) Log

func (b *SyslogBackend) Log(msg Message)

type SyslogBackendCfg

type SyslogBackendCfg struct {
	Addr            string `json:"addr"`
	ApplicationName string `json:"application_name"`
}

type TerminalBackend

type TerminalBackend struct {
	Cfg TerminalBackendCfg
	// contains filtered or unexported fields
}

func NewTerminalBackend

func NewTerminalBackend(cfg TerminalBackendCfg) *TerminalBackend

func (*TerminalBackend) Colorize

func (b *TerminalBackend) Colorize(color Color, s string) string

func (*TerminalBackend) Log

func (b *TerminalBackend) Log(msg Message)

type TerminalBackendCfg

type TerminalBackendCfg struct {
	Color       bool `json:"color"`
	DomainWidth int  `json:"domain_width"`
}

Jump to

Keyboard shortcuts

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