log

package module
v0.0.0-...-7ec0d2c Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2019 License: Apache-2.0 Imports: 30 Imported by: 0

README

#Log

Build Status GoDoc

Log package is much like the go log package. But it have a fill more tricks, like backends and filters.

#Normal use

First import: import "github.com/fcavani/log" Than use one of the free functions in the documentation.

// Normal log
log.Println("log this")
// Log error
log.Error("Error:", err)
// Log fatal, fallowed by a os.Exit(1) call
log.Fatal("Can't handle this error:", err)
// Panic, calls panic after log. Maybe because the backend the log may get lost.
log.Panic("panic!")

Modificators:

// Associate a tag with the log.
log.Tag("tag").Println("test")
// More tags
log.Tag("tag1", "tag2").Println("test")
// Determine the level
log.ProtoLevel().Println("some dirty protocol thing")

Setting the default level:

log.SetLevel("all", log.WarnPrio)

In place of "all", you can put the name of one package, than that level will be restrict to this package. You can repeat this functions for any package.

#Change the log format

You can change the format of the log entry. In NewStdFormatter we have the separator, the template, with fields named after the struct that implements Entry interface, a sample of that struct, a map with values that appears in template string but not appears in the struct, like host in the example below.

form, _ := log.NewStdFormatter(
  "::",
  "::host - ::domain - ::date - ::level - ::tags - ::file ::msg",
  log.Log,
  map[string]interface{}{
    "host": hostname,
  }
)

To use this format: log.Log.Formatter(form)

#Considerations about speed

Below is the table with the go benchmark for some loggers packages (PureGolog, GoLogging, Logrus) and for some cases with different backends. All three loggers above was set to log to /dev/null, and use the most simple configuration that I can find, thus they will have good performance, with is the case for the go log, it is the most simple and the base line for the others. In some cases this logger can win Logrus, the slower logger between the other two, but I doubt that StoreMap, that stores all logged data into memory, will have practical use by anyone.

Name N Time Rate
BenchmarkPureGolog-4 1000000 1465 ns/op 12.28 MB/s
BenchmarkGoLogging-4 1000000 2235 ns/op 8.05 MB/s
BenchmarkLogrus-4 300000 5167 ns/op 3.48 MB/s
BenchmarkGolog-4 200000 6483 ns/op 2.78 MB/s
BenchmarkLogStderr-4 200000 5641 ns/op 3.19 MB/s
BenchmarkLogFile-4 200000 8276 ns/op 2.17 MB/s
BenchmarkLogFileBuffer-4 300000 4838 ns/op 3.72 MB/s
BenchmarkStoreMap-4 500000 3749 ns/op 4.80 MB/s
BenchmarkBoltDb-4 3000 552564 ns/op 0.03 MB/s
BenchmarkBoltDbBuffer-4 5000 270518 ns/op 0.07 MB/s
BenchmarkMongoDb-4 2000 1052129 ns/op 0.02 MB/s
BenchmarkMongoDbBuffer-4 100 11864291 ns/op 0.00 MB/s
BenchmarkLogOuterNull-4 200000 8006 ns/op 2.25 MB/s
BenchmarkLogOuterFile-4 100000 15351 ns/op 1.17 MB/s

LogFileBuffer is interesting if you can setup a buffer larger enough to accommodate all income data without saturate the buffer. In this tests the buffer was set to half the size of b.N, the number of runs in the second column. Because this the buffer is relevant until it is full in the half of the test than the backend operate normally, without buffer, to the end of the test. Thus we have in the third column one number that shows the buffer working but shows too the backend working without buffer.

Using buffers in log application create a latency between the time the event occurs and the time that someone or some log analyser will see the event, for that reason it is not suitable for real time application. But for small applications, that latency not will compromise the operation, even the file log without buffer will work.

For the database (BoltDb and MongoDb), I don't have information if this numbers correspond to the reality. In the case of MongoDb with buffers the number of runs is too small, the buffer size become a problem and make the backend work slower.

The last two rows are for cases where you want to plug one logger to this one. I use this to redirect the yamux logger to my logger.

This logger can offer much customizations, you can make a new entry, a new formatter and backends. You can mix all backends with all filters and make a great custom logger easily, but its slow. :) It's the first version too.

#Backends

The backend is responsable to put the log entry in some place. The backends avalible are:

  • NewSendToLogger(logger *golog.Logger) LogBackend - Only to demonstrate, send all log entries to go logger.
  • NewWriter(w io.Writer) LogBackend - Log to a writer. It can be a file or anything.
  • NewGeneric(s Storer) LogBackend - Log to anything that implements a Storer interface.
  • NewSyslog(w *syslog.Writer) LogBackend - Log to syslog.
  • NewMulti(vals ...interface{}) LogBackend - Log the data to multiples backends. The syntax is: first the backend followed by the formattter, than another backend and follows like this.
  • NewOutBuffer(bak LogBackend, size int) LogBackend - NewOutBuffer creates a buffer between the bak backend and the commit of a new log entry. It can improve the latency of commit but delays the final store, with can't cause log miss if the application shutdown improperly (without close the buffer) or panic before the buffer become empty.

Anything that implements the LogBackend interface can be used to store the log entry.

Example 1

// Write to stdout with DefFormatter formatter.
Log = log.New(
  log.NewWriter(os.Stdout).F(log.DefFormatter),
  false,
)

Example 2

// Write to stdout and to MongoDb
mongodb, _ = log.NewMongoDb(...)
Log = log.New(
  log.NewMulti(
    log.NewWriter(os.Stdout),
    log.DefFormatter,
    log.NewGeneric(mongodb),
    log.DefFormatter,
  ),
  false,
)

#Filters

With filter you can chose what you will see in each backend. In the example below if the field msg not (log.Not) contains (log.Cnts) "not log" the message will be logged. The principal function is the log.Op(o Operation, field string, vleft ...interface{}) Ruler. In this function you can use others operations like Cnts and you can modify the result of it with the function log.Not or you can combine the result with others Op functions with log.And and log.Or. Like the backends anything that implements Ruler interface can be used to filter one log entry.

Example

Log = log.New(
  log.Filter(
    log.NewWriter(buf),
    log.Not(log.Op(log.Cnts, "msg", "not log")),
  ).F(log.DefFormatter),
  false,
)

#Storer

Stores with NewGeneric(s Storer) can put the logs entries in any place for future analysis. All stores must respect the Storer interface, that is a simple CRUD like interface with the DB inspired in the BoltDb API. This is the stores available:

Documentation

Overview

This packages works like go log package. Use the functions of the family of Print, Error or Fatal like in go. See docs for more functions and how you could customize your log messages and you storage backends.

Index

Constants

View Source
const (
	LeftToRight dir = iota
	RightToLeft
)
View Source
const ErrDataNotComp = "data type is not compatible, use a struct"
View Source
const ErrFirstChar = "first char must be letter"
View Source
const ErrInvKey = "invalid key"
View Source
const ErrKeyFound = "key found"
View Source
const ErrKeyNotFound = "key not found"
View Source
const ErrNoSubs = "variable %v have no substitution"
View Source
const ErrNotSupported = "this format isn't made for this entry"
View Source
const ErrReadOnly = "read only transaction"

Variables

View Source
var DateFormat = time.RFC3339
View Source
var MaxProbeName = 50
View Source
var MinProbeName = 1
View Source
var RecoverBufferStack = 10485760

RecoverBufferStack amont of buffer to store the stack.

View Source
var TimeDateFormat = time.RFC822

Functions

func CommitFail

func CommitFail(entry Entry, err error)

func Error

func Error(vals ...interface{})

func Errorf

func Errorf(s string, vals ...interface{})

func Errorln

func Errorln(vals ...interface{})

func Fail

func Fail(err error)

func Fatal

func Fatal(vals ...interface{})

func Fatalf

func Fatalf(s string, vals ...interface{})

func Fatalln

func Fatalln(vals ...interface{})

func GoPanic

func GoPanic(r interface{}, stack []byte, cont bool)

func New

func New(b LogBackend, debug bool) *log

func Panic

func Panic(vals ...interface{})

func Panicf

func Panicf(s string, vals ...interface{})

func Panicln

func Panicln(vals ...interface{})

func Print

func Print(vals ...interface{})

func Printf

func Printf(str string, vals ...interface{})

func Println

func Println(vals ...interface{})

func Recover

func Recover(notexit bool)

Recover from panic and log the stack. If notexit is false, call os.Exit(1), if not continue.

func ValProbeName

func ValProbeName(name string) error

Types

type BoltDb

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

func (*BoltDb) Close

func (db *BoltDb) Close() error

func (*BoltDb) Drop

func (db *BoltDb) Drop() error

func (*BoltDb) Len

func (db *BoltDb) Len() (l uint, err error)

func (*BoltDb) SupportTx

func (b *BoltDb) SupportTx() bool

func (*BoltDb) Tx

func (db *BoltDb) Tx(write bool, f func(tx Transaction) error) error

type Cursor

type Cursor interface {
	First() (key string, data interface{})
	Last() (key string, data interface{})
	Seek(wanted string) (key string, data interface{})
	Next() (key string, data interface{})
	Prev() (key string, data interface{})
	Del() error
}

type Decoder

type Decoder interface {
	Decode(buf []byte) (interface{}, error)
}

type Encoder

type Encoder interface {
	Encode(i interface{}) ([]byte, error)
}

type Entry

type Entry interface {
	// Date returns the time stamp of the log
	Date() time.Time
	// Level return the log level
	Level() Level
	// Message returns the formated message
	Message() string
	//Tags return the tags in a log entry
	Tags() *tags.Tags
	//Domain is the domain of the log
	Domain(d string) Logger
	//GetDomain return the current domain of the log.
	GetDomain() string
	// Error returns any erro cocurred after caling one function.
	Err() error
	// String return the formated log
	String() string
	// Bytes return the formated log in bytes
	Bytes() []byte
	// Formatter sets the formater for that entry
	Formatter(f Formatter)
	// Sorter set one filter for the backend associated with the logger.
	// This filter works after the filter set in the New statment.
	Sorter(r Ruler) Logger
	// SetLevel sets the log Level for this logger. Scope all setlevel for everything.
	// If Scope is a packege set log level only for this package.
	SetLevel(scope string, l Level) Logger
	// EntryLevel set the level for this log entry.
	EntryLevel(l Level) Logger
	// DebugInfo write into the struct debug information.
	DebugInfo() Logger
}

type False

type False struct{}

False ruler return always false

func (False) Result

func (f False) Result(entry Entry) bool

type Formatter

type Formatter interface {
	// Format formats the template replace the marks with the contents of m.
	Format(entry Entry) (out []byte, err error)
	// Mark change the replacement mark of the template
	Mark(mark string)
	// Template replaces the template string
	Template(t string)
	// Entry mark this formater to work only its type of entry
	Entry(entry Entry)
	// NewEntry creates a new log entry
	NewEntry(b LogBackend) Logger
	// Set the time format string if empty use the default.
	SetTimeFormat(s string)
}
var DefFormatter Formatter

func NewStdFormatter

func NewStdFormatter(delim, tmpl string, entry Entry, values map[string]interface{}, timeformat string) (Formatter, error)

NewStdFormatter crete a new formatter.

type Generic

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

func (*Generic) Close

func (g *Generic) Close() error

func (*Generic) Commit

func (g *Generic) Commit(entry Entry)

func (*Generic) F

func (g *Generic) F(f Formatter) LogBackend

func (*Generic) Filter

func (g *Generic) Filter(r Ruler) LogBackend

func (*Generic) GetF

func (g *Generic) GetF() Formatter

func (*Generic) OuterLog

func (g *Generic) OuterLog(level Level, tags ...string) io.Writer

type Gob

type Gob struct {
	TypeName string
}

func (*Gob) Decode

func (g *Gob) Decode(b []byte) (interface{}, error)

func (*Gob) Encode

func (g *Gob) Encode(i interface{}) ([]byte, error)

type If

type If struct {
	Condition Ruler
	Than      Ruler
}

type Level

type Level uint8
const (
	ProtoPrio Level = iota //More priority
	DebugPrio
	InfoPrio
	WarnPrio
	ErrorPrio
	FatalPrio
	PanicPrio
	NoPrio //Less priority
)

func ParseLevel

func ParseLevel(level string) (Level, error)

func (Level) String

func (l Level) String() string

type Levels

type Levels interface {
	// ProtoLevel set the log level to protocol
	ProtoLevel() Logger
	// DebugLevel set the log level to debug
	DebugLevel() Logger
	// InfoLevel set the log level to info
	InfoLevel() Logger
	// WarnLevel set the log level to warn
	WarnLevel() Logger
	// ErrorLevel set the log level to error
	ErrorLevel() Logger
	// FatalLevel set the log level to fatal
	FatalLevel() Logger
	// PanicLevel set the log level to panic
	PanicLevel() Logger
}

type LogBackend

type LogBackend interface {
	// Commit send the log to the persistence layer.
	Commit(entry Entry)
	// F sets the formater for this backend.
	F(f Formatter) LogBackend
	// GetF returns the Formatter for this backend.
	GetF() Formatter
	//Filter change the filter associated to this backend
	Filter(r Ruler) LogBackend
	//Close stop the backend and flush all entries.
	Close() error
}

func Filter

func Filter(l LogBackend, r Ruler) LogBackend

Filter creates a new filter with rules r for l backend.

func NewGeneric

func NewGeneric(s Storer) LogBackend

func NewMulti

func NewMulti(vals ...interface{}) LogBackend

NewMulti creates a MultiLog

func NewOutBuffer

func NewOutBuffer(bak LogBackend, size int) LogBackend

func NewSendToLogger

func NewSendToLogger(logger *golog.Logger) LogBackend

NewSendToLogger creates a logger from a go log.

func NewSyslog

func NewSyslog(w *syslog.Writer) LogBackend

func NewWriter

func NewWriter(w io.Writer) LogBackend

NewWriter creates a backend that log to w.

func Store

func Store() LogBackend

type Logfmt

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

func NewLogfmt

func NewLogfmt(w io.Writer) *Logfmt

func (*Logfmt) Close

func (l *Logfmt) Close() error

func (*Logfmt) Commit

func (l *Logfmt) Commit(entry Entry)

func (*Logfmt) F

func (l *Logfmt) F(f Formatter) LogBackend

func (*Logfmt) Filter

func (l *Logfmt) Filter(r Ruler) LogBackend

func (*Logfmt) GetF

func (l *Logfmt) GetF() Formatter

type Logfmter

type Logfmter interface {
	Logfmt(enc *logfmt.Encoder) error
}

Logfmter encode a log entry in logfmt format.

type Logger

type Logger interface {
	Entry
	Levels
	Tagger
	TemplateSetup
	StdLogger
	Storage
	PanicStack
	Error(...interface{})
	Errorf(string, ...interface{})
	Errorln(...interface{})
}
var Log Logger

func DebugLevel

func DebugLevel() Logger

func Domain

func Domain(d string) Logger

func EntryLevel

func EntryLevel(prio Level) Logger

func ErrorLevel

func ErrorLevel() Logger

func FatalLevel

func FatalLevel() Logger

func GetLogger

func GetLogger() Logger

func InfoLevel

func InfoLevel() Logger

func Mark

func Mark(mark string) Logger

func PanicLevel

func PanicLevel() Logger

func ProtoLevel

func ProtoLevel() Logger

func SetLevel

func SetLevel(scope string, l Level) Logger

func SetStore

func SetStore(b LogBackend) Logger

func Sorter

func Sorter(r Ruler) Logger

func Tag

func Tag(tags ...string) Logger

func Template

func Template(t string) Logger

func WarnLevel

func WarnLevel() Logger

type Map

type Map struct {
	M   map[string]interface{}
	Idx []string
	// contains filtered or unexported fields
}

func (*Map) Close

func (m *Map) Close() error

func (*Map) Drop

func (m *Map) Drop() error

func (*Map) Len

func (m *Map) Len() (uint, error)

func (*Map) SupportTx

func (m *Map) SupportTx() bool

func (*Map) Tx

func (m *Map) Tx(write bool, f func(tx Transaction) error) error

type MongoDb

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

func (*MongoDb) Close

func (m *MongoDb) Close() error

func (*MongoDb) Drop

func (m *MongoDb) Drop() error

Drop clears the database

func (*MongoDb) Len

func (m *MongoDb) Len() (l uint, err error)

func (*MongoDb) SupportTx

func (m *MongoDb) SupportTx() bool

func (*MongoDb) Tx

func (m *MongoDb) Tx(write bool, f func(tx Transaction) error) error

type MultiLog

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

MultiLog copy the log entry to multiples backends.

func (*MultiLog) Close

func (mp *MultiLog) Close() error

func (*MultiLog) Commit

func (mp *MultiLog) Commit(entry Entry)

func (*MultiLog) F

func (mp *MultiLog) F(f Formatter) LogBackend

func (*MultiLog) Filter

func (mp *MultiLog) Filter(r Ruler) LogBackend

func (*MultiLog) GetF

func (mp *MultiLog) GetF() Formatter

func (*MultiLog) OuterLog

func (mp *MultiLog) OuterLog(level Level, tags ...string) io.Writer

outerLog is like outers outerLogs but the nem entry is created from the first BackLog in the list.

type Operation

type Operation uint8

Operation defines one operator for the rules.

const (
	// Equal
	Eq Operation = iota
	// Not equal
	Ne
	// Less than
	Lt
	// Greater than
	Gt
	// Less equal
	Le
	// Greater equal
	Ge
	// Not
	N
	// Exits in tags
	Ex
	// Contains
	Cnts
	// Regexp
	Re
	// Pr matches the begin of string
	Pr
)

type OutBuffer

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

func (*OutBuffer) Close

func (o *OutBuffer) Close() error

func (*OutBuffer) Commit

func (o *OutBuffer) Commit(entry Entry)

func (*OutBuffer) F

func (o *OutBuffer) F(f Formatter) LogBackend

func (*OutBuffer) Filter

func (o *OutBuffer) Filter(r Ruler) LogBackend

func (*OutBuffer) GetF

func (o *OutBuffer) GetF() Formatter

type OuterLogger

type OuterLogger interface {
	// OtherLog creats a writer that receive log entries separeted by \n.
	OuterLog(level Level, tags ...string) io.Writer
	// Close closses the outer logger. If not closed you will have a leeked gorotine.
	Close() error
}

OtherLogger provides a interface to plug via a writer another logger to this logger, in this case the backend that implements OtherLogger

type PanicStack

type PanicStack interface {
	// GoPanic handle a panic where r is the value of recover()
	// stack is the buffer where will be the stack dump and cont is false if
	// GoPanic will call os.Exit(1).
	GoPanic(r interface{}, stack []byte, cont bool)
}

type Ruler

type Ruler interface {
	Result(entry Entry) bool
}

func And

func And(v ...Ruler) Ruler

And operator between two rules.

func ApplyRuleIf

func ApplyRuleIf(condition, rule Ruler) Ruler

ApplyRuleIf test if condition is true than apply rule. If condition is false do nothing, return true.

func ApplyRuleIfElse

func ApplyRuleIfElse(condition, rule, el Ruler) Ruler

ApplyRuleIfElse test if condition is true than apply rule. If condition is false run else rule.

func Not

func Not(r Ruler) Ruler

Not operator for one rule.

func Op

func Op(o Operation, field string, vleft ...interface{}) Ruler

Op is an operation in some field and with some value.

func Or

func Or(v ...Ruler) Ruler

Or operator between two rules.

func Select

func Select(ifs []*If, def Ruler) Ruler

type SendToLogger

type SendToLogger struct {
	*golog.Logger
	// contains filtered or unexported fields
}

SendToLogger simple log that forward all logged messages to go log.

func (*SendToLogger) Close

func (s *SendToLogger) Close() error

func (*SendToLogger) Commit

func (s *SendToLogger) Commit(entry Entry)

func (*SendToLogger) F

func (*SendToLogger) Filter

func (s *SendToLogger) Filter(r Ruler) LogBackend

func (*SendToLogger) GetF

func (s *SendToLogger) GetF() Formatter

type StdFormatter

type StdFormatter struct {
	// Delim: every fild in Tmpl are preceded by it.
	Delim []byte
	// Tmpl is the template and are compose by deliminator fallowed by labels
	Tmpl []byte
	// E is the Entry. This fild are only used for struct analasy of E.
	E Entry
	// Map holds the replacements for labels that aren't found in E.
	Map map[string]interface{}
	// Idx are the index of the fild. Don't change.
	Idx map[string]struct {
		I   int
		Def string
	}
	// TimeFormat is the string with the template of date and time format.
	TimeFormat string
}

StdFormatter is a formatter for the log data. The fild in Entry are match with the fields in Tmpl, the tags in Entry are considered.

func (*StdFormatter) Entry

func (s *StdFormatter) Entry(entry Entry)

func (StdFormatter) Format

func (s StdFormatter) Format(entry Entry) (out []byte, err error)

func (*StdFormatter) Mark

func (s *StdFormatter) Mark(delim string)

func (*StdFormatter) NewEntry

func (s *StdFormatter) NewEntry(b LogBackend) Logger

func (*StdFormatter) SetTimeFormat

func (s *StdFormatter) SetTimeFormat(format string)

func (*StdFormatter) Template

func (s *StdFormatter) Template(t string)

type StdLogger

type StdLogger interface {
	Print(...interface{})
	Printf(string, ...interface{})
	Println(...interface{})

	Fatal(...interface{})
	Fatalf(string, ...interface{})
	Fatalln(...interface{})

	Panic(...interface{})
	Panicf(string, ...interface{})
	Panicln(...interface{})
}

type Storage

type Storage interface {
	// Store give access to the persistence storage
	Store() LogBackend
	// SetStore allow you to set a new persistence store to the logger
	SetStore(p LogBackend) Logger
}

type StoreFake

type StoreFake struct{}

func (StoreFake) SupportTx

func (s StoreFake) SupportTx() bool

func (StoreFake) Tx

func (s StoreFake) Tx(write bool, f func(tx Transaction) error) error

type Storer

type Storer interface {
	SupportTx() bool
	Tx(write bool, f func(tx Transaction) error) error
	Len() (uint, error)
	Drop() error
	Close() error
}

func NewBoltDb

func NewBoltDb(bucket, path string, mode os.FileMode, options *bolt.Options, enc Encoder, dec Decoder) (Storer, error)

func NewMap

func NewMap(size int) (Storer, error)

func NewMongoDb

func NewMongoDb(rawurl, collection string, safe *mgo.Safe, entry Entry, timeout time.Duration) (Storer, error)

type Syslog

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

Syslog sends all messages to syslog.

func (*Syslog) Close

func (s *Syslog) Close() error

func (*Syslog) Commit

func (s *Syslog) Commit(entry Entry)

func (*Syslog) F

func (s *Syslog) F(f Formatter) LogBackend

F: syslog don't need a formatter.

func (*Syslog) Filter

func (s *Syslog) Filter(r Ruler) LogBackend

func (*Syslog) GetF

func (s *Syslog) GetF() Formatter

GetF always return nil, syslog don't need a formatter.

type Tagger

type Tagger interface {
	// Tag attach a tag
	Tag(tags ...string) Logger
}

type TemplateSetup

type TemplateSetup interface {
	// Mark change the replacement mark of the template
	Mark(mark string) Logger
	// Template replaces the template string
	Template(t string) Logger
}

type TestStruct

type TestStruct struct {
	Key string `bson:"key"`
	I   int
}

func (*TestStruct) Bytes

func (et *TestStruct) Bytes() []byte

func (*TestStruct) Date

func (et *TestStruct) Date() time.Time

func (*TestStruct) DebugInfo

func (et *TestStruct) DebugInfo() Logger

func (*TestStruct) Domain

func (et *TestStruct) Domain(d string) Logger

func (*TestStruct) EntryLevel

func (et *TestStruct) EntryLevel(l Level) Logger

func (*TestStruct) Err

func (et *TestStruct) Err() error

func (*TestStruct) Formatter

func (et *TestStruct) Formatter(f Formatter)

func (*TestStruct) GetDomain

func (et *TestStruct) GetDomain() string

func (*TestStruct) Level

func (et *TestStruct) Level() Level

func (*TestStruct) Message

func (et *TestStruct) Message() string

func (*TestStruct) SetLevel

func (et *TestStruct) SetLevel(scope string, level Level) Logger

func (*TestStruct) Sorter

func (et *TestStruct) Sorter(r Ruler) Logger

func (*TestStruct) String

func (et *TestStruct) String() string

func (*TestStruct) Tags

func (et *TestStruct) Tags() *tags.Tags

type Transaction

type Transaction interface {
	Put(key string, data interface{}) error
	Get(key string) (interface{}, error)
	Del(key string) error
	Cursor() Cursor
}

type True

type True struct{}

True ruler return alway true

func (True) Result

func (t True) Result(entry Entry) bool

type Writer

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

Writer log to an io.Writer

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Commit

func (w *Writer) Commit(entry Entry)

func (*Writer) F

func (w *Writer) F(f Formatter) LogBackend

func (*Writer) Filter

func (w *Writer) Filter(r Ruler) LogBackend

func (*Writer) GetF

func (w *Writer) GetF() Formatter

func (*Writer) OuterLog

func (w *Writer) OuterLog(level Level, tags ...string) io.Writer

func (*Writer) Writer

func (w *Writer) Writer(writter io.Writer)

Jump to

Keyboard shortcuts

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