log

package module
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2020 License: MIT Imports: 6 Imported by: 1

README

Log

Go logging simplified.

	var err error
	var l = log.V(0)

	// nil errors get ignored
	l.Err(err)

	// non nil errors are printed
	err = errors.New("we log non nil errors")
	l.Err(err)

	// or just write a string
	l.Str("hello")

	// and format it sometimes
	l.Strf("hello %s", "world")

Documentation

Index

Constants

View Source
const (
	Skip       = 2
	TimeFormat = "Mon, 02 Jan 2006 15:04:05.999 UTC"
	Verbosity  = 255
)

Variables

View Source
var Error = V(1)
View Source
var Fatal = V(0)
View Source
var Info = V(3)
View Source
var V = New()
View Source
var Warning = V(2)
View Source
var Writer = os.Stdout

Functions

func New added in v0.6.0

func New(options ...Option) func(Level) Logger

Types

type Config

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

func (*Config) Apply added in v0.6.0

func (c *Config) Apply(options ...Option)

type Level

type Level uint8

type Log added in v0.6.0

type Log struct {
	Level  Level               `json:"level"`
	At     string              `json:"at"`
	Log    string              `json:"log"`
	File   string              `json:"file,omitempty"`
	Fields map[string][]string `json:"fields,omitempty"`
}

func (Log) Bytes added in v0.6.0

func (l Log) Bytes() []byte

type Logger

type Logger func(string)

func (Logger) Err

func (l Logger) Err(err error)

func (Logger) Str

func (l Logger) Str(s string)

func (Logger) Strf

func (l Logger) Strf(s string, args ...interface{})

type Option added in v0.1.1

type Option func(*Config)

func WithSkip added in v0.3.0

func WithSkip(skip int) Option

func WithTimeFormat added in v0.1.1

func WithTimeFormat(tf string) Option

func WithVerbosity added in v0.1.1

func WithVerbosity(v uint8) Option

func WithWriter added in v0.1.1

func WithWriter(w io.Writer) Option

Source Files

  • config.go
  • default.go
  • level.go
  • log.go
  • logger.go
  • option.go

Jump to

Keyboard shortcuts

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