log

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package log is inspired by apex/log.

Index

Constants

This section is empty.

Variables

View Source
var Discard = discard{}
View Source
var Now = time.Now

Now returns the current time.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Timestamp time.Time
	Level     Level
	Message   string
	Fields    Fields
}

type Field

type Field struct {
	Key   string
	Value interface{}
}

type Fields

type Fields map[string]interface{}

func (Fields) Get added in v0.2.6

func (f Fields) Get(key string) interface{}

func (Fields) Keys added in v0.2.6

func (f Fields) Keys() []string

type Handler

type Handler interface {
	Log(log *Entry) error
}

type Level

type Level uint8

Level of the logger

const (
	DebugLevel Level = iota + 1
	InfoLevel
	NoticeLevel
	WarnLevel
	ErrorLevel
)

Log level

func ParseLevel

func ParseLevel(level string) (Level, error)

func (Level) String

func (level Level) String() string

type Log added in v0.2.6

type Log interface {
	Field(key string, value interface{}) Log
	Fields(fields map[string]interface{}) Log
	Debug(msg string, args ...interface{}) error
	Info(msg string, args ...interface{}) error
	Notice(msg string, args ...interface{}) error
	Warn(msg string, args ...interface{}) error
	Error(msg string, args ...interface{}) error
	Err(err error, msg string, args ...interface{}) error
}

func Error added in v0.2.6

func Error(log Log, err error) Log

type Logger

type Logger struct {
	Handler Handler
}

func New

func New(handler Handler) *Logger

New logger

func (*Logger) Debug

func (l *Logger) Debug(msg string, args ...interface{}) error

func (*Logger) Err added in v0.2.6

func (l *Logger) Err(err error, msg string, args ...interface{}) error

func (*Logger) Error

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

func (*Logger) Field added in v0.2.6

func (l *Logger) Field(key string, value interface{}) Log

func (*Logger) Fields added in v0.2.6

func (l *Logger) Fields(fields map[string]interface{}) Log

func (*Logger) Info

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

func (*Logger) Notice

func (l *Logger) Notice(msg string, args ...interface{}) error

func (*Logger) Warn

func (l *Logger) Warn(msg string, args ...interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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