Documentation
¶
Overview ¶
Package log is inspired by apex/log.
Index ¶
- Variables
- func Buffer() *bufferHandler
- type Entry
- type Fields
- type Handler
- type Level
- type Log
- type Logger
- func (l *Logger) Debug(args ...interface{}) error
- func (l *Logger) Debugf(msg string, args ...interface{}) error
- func (l *Logger) Error(args ...interface{}) error
- func (l *Logger) Errorf(msg string, args ...interface{}) error
- func (l *Logger) Field(key string, value interface{}) Log
- func (l *Logger) Fields(fields map[string]interface{}) Log
- func (l *Logger) Info(args ...interface{}) error
- func (l *Logger) Infof(msg string, args ...interface{}) error
- func (l *Logger) Notice(args ...interface{}) error
- func (l *Logger) Noticef(msg string, args ...interface{}) error
- func (l *Logger) Warn(args ...interface{}) error
- func (l *Logger) Warnf(msg string, args ...interface{}) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Debug message is written to the console Debug = stderr.Debug // Debugf message is written to the console Debugf = stderr.Debugf // Info message is written to the console Info = stderr.Info // Infof message is written to the console Infof = stderr.Infof // Notice message is written to the console Notice = stderr.Notice // Noticef message is written to the console Noticef = stderr.Noticef // Warn message is written to the console Warn = stderr.Warn // Warnf message is written to the console Warnf = stderr.Warnf // Error message is written to the console Error = stderr.Error // Errorf message is written to the console Errorf = stderr.Errorf )
View Source
var Discard = discard{}
View Source
var Now = time.Now
Now returns the current time.
Functions ¶
Types ¶
type Entry ¶ added in v0.0.3
type Entry struct {
Time time.Time `json:"time,omitempty"`
Level Level `json:"level,omitempty"`
Message string `json:"msg,omitempty"`
Fields Fields `json:"fields,omitempty"`
}
func (*Entry) MarshalJSON ¶ added in v0.0.3
type Handler ¶
func Console ¶
Console handler
Example ¶
package main
import (
"os"
"github.com/livebud/color"
"github.com/livebud/log"
)
func main() {
log := log.New(log.Console(color.Ignore(), os.Stdout))
log.Debug("world", "args", 10)
log.Info("hello", "planet", "world", "args", 10)
log.Warn("hello", "planet", "world", "args", 10)
// log.Error("hello world", slog.String("planet", "world"), "args", 10)
type Log ¶ added in v0.0.3
type Log interface {
Field(key string, value interface{}) Log
Fields(fields map[string]interface{}) Log
Debug(args ...interface{}) error
Debugf(msg string, args ...interface{}) error
Info(args ...interface{}) error
Infof(msg string, args ...interface{}) error
Notice(args ...interface{}) error
Noticef(msg string, args ...interface{}) error
Warn(args ...interface{}) error
Warnf(msg string, args ...interface{}) error
Error(args ...interface{}) error
Errorf(msg string, args ...interface{}) error
}
func Multi ¶
Multi logs to multiple places
Example ¶
package main
import (
"os"
"github.com/livebud/color"
"github.com/livebud/log"
)
func main() {
log := log.Multi(
log.Filter(log.LevelInfo, log.Console(color.Ignore(), os.Stderr)),
log.Json(os.Stderr),
)
log.Debug("world", "args", 10)
log.Info("hello", "planet", "world", "args", 10)
log.Warn("hello", "planet", "world", "args", 10)
log.Error("hello world", "planet", "world", "args", 10)
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.