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
- Variables
- func CommitFail(entry Entry, err error)
- func Error(vals ...interface{})
- func Errorf(s string, vals ...interface{})
- func Errorln(vals ...interface{})
- func Fail(err error)
- func Fatal(vals ...interface{})
- func Fatalf(s string, vals ...interface{})
- func Fatalln(vals ...interface{})
- func GoPanic(r interface{}, stack []byte, cont bool)
- func New(b LogBackend, debug bool) *log
- func Panic(vals ...interface{})
- func Panicf(s string, vals ...interface{})
- func Panicln(vals ...interface{})
- func Print(vals ...interface{})
- func Printf(str string, vals ...interface{})
- func Println(vals ...interface{})
- func Recover(notexit bool)
- func ValProbeName(name string) error
- type BoltDb
- type Cursor
- type Decoder
- type Encoder
- type Entry
- type False
- type Formatter
- type Generic
- type Gob
- type If
- type Level
- type Levels
- type LogBackend
- func Filter(l LogBackend, r Ruler) LogBackend
- func NewGeneric(s Storer) LogBackend
- func NewMulti(vals ...interface{}) LogBackend
- func NewOutBuffer(bak LogBackend, size int) LogBackend
- func NewSendToLogger(logger *golog.Logger) LogBackend
- func NewSyslog(w *syslog.Writer) LogBackend
- func NewWriter(w io.Writer) LogBackend
- func Store() LogBackend
- type Logfmt
- type Logfmter
- type Logger
- func DebugLevel() Logger
- func Domain(d string) Logger
- func EntryLevel(prio Level) Logger
- func ErrorLevel() Logger
- func FatalLevel() Logger
- func GetLogger() Logger
- func InfoLevel() Logger
- func Mark(mark string) Logger
- func PanicLevel() Logger
- func ProtoLevel() Logger
- func SetLevel(scope string, l Level) Logger
- func SetStore(b LogBackend) Logger
- func Sorter(r Ruler) Logger
- func Tag(tags ...string) Logger
- func Template(t string) Logger
- func WarnLevel() Logger
- type Map
- type MongoDb
- type MultiLog
- type Operation
- type OutBuffer
- type OuterLogger
- type PanicStack
- type Ruler
- type SendToLogger
- type StdFormatter
- type StdLogger
- type Storage
- type StoreFake
- type Storer
- type Syslog
- type Tagger
- type TemplateSetup
- type TestStruct
- func (et *TestStruct) Bytes() []byte
- func (et *TestStruct) Date() time.Time
- func (et *TestStruct) DebugInfo() Logger
- func (et *TestStruct) Domain(d string) Logger
- func (et *TestStruct) EntryLevel(l Level) Logger
- func (et *TestStruct) Err() error
- func (et *TestStruct) Formatter(f Formatter)
- func (et *TestStruct) GetDomain() string
- func (et *TestStruct) Level() Level
- func (et *TestStruct) Message() string
- func (et *TestStruct) SetLevel(scope string, level Level) Logger
- func (et *TestStruct) Sorter(r Ruler) Logger
- func (et *TestStruct) String() string
- func (et *TestStruct) Tags() *tags.Tags
- type Transaction
- type True
- type Writer
Constants ¶
const ( LeftToRight dir = iota RightToLeft )
const ErrDataNotComp = "data type is not compatible, use a struct"
const ErrFirstChar = "first char must be letter"
const ErrInvKey = "invalid key"
const ErrKeyFound = "key found"
const ErrKeyNotFound = "key not found"
const ErrNoSubs = "variable %v have no substitution"
const ErrNotSupported = "this format isn't made for this entry"
const ErrReadOnly = "read only transaction"
Variables ¶
var DateFormat = time.RFC3339
var MaxProbeName = 50
var MinProbeName = 1
var RecoverBufferStack = 10485760
RecoverBufferStack amont of buffer to store the stack.
var TimeDateFormat = time.RFC822
Functions ¶
func CommitFail ¶
func New ¶
func New(b LogBackend, debug bool) *log
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 ¶
Types ¶
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 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
type Generic ¶
type Generic struct {
// contains filtered or unexported fields
}
func (*Generic) F ¶
func (g *Generic) F(f Formatter) LogBackend
func (*Generic) Filter ¶
func (g *Generic) Filter(r Ruler) LogBackend
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 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 Store ¶
func Store() LogBackend
type Logfmt ¶
type Logfmt struct {
// contains filtered or unexported fields
}
func (*Logfmt) F ¶
func (l *Logfmt) F(f Formatter) LogBackend
func (*Logfmt) Filter ¶
func (l *Logfmt) Filter(r Ruler) LogBackend
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 EntryLevel ¶
func ErrorLevel ¶
func ErrorLevel() Logger
func FatalLevel ¶
func FatalLevel() Logger
func PanicLevel ¶
func PanicLevel() Logger
func ProtoLevel ¶
func ProtoLevel() Logger
func SetStore ¶
func SetStore(b LogBackend) Logger
type MultiLog ¶
type MultiLog struct {
// contains filtered or unexported fields
}
MultiLog copy the log entry to multiples backends.
func (*MultiLog) F ¶
func (mp *MultiLog) F(f Formatter) LogBackend
func (*MultiLog) Filter ¶
func (mp *MultiLog) Filter(r Ruler) LogBackend
type OutBuffer ¶
type OutBuffer struct {
// contains filtered or unexported fields
}
func (*OutBuffer) F ¶
func (o *OutBuffer) F(f Formatter) LogBackend
func (*OutBuffer) Filter ¶
func (o *OutBuffer) Filter(r Ruler) LogBackend
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 Ruler ¶
func ApplyRuleIf ¶
ApplyRuleIf test if condition is true than apply rule. If condition is false do nothing, return true.
func ApplyRuleIfElse ¶
ApplyRuleIfElse test if condition is true than apply rule. If condition is false run else rule.
type SendToLogger ¶
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 (s *SendToLogger) F(f Formatter) LogBackend
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) 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 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 Storer ¶
type Storer interface { SupportTx() bool Tx(write bool, f func(tx Transaction) error) error Len() (uint, error) Drop() error Close() error }
type Syslog ¶
type Syslog struct {
// contains filtered or unexported fields
}
Syslog sends all messages to syslog.
func (*Syslog) Filter ¶
func (s *Syslog) Filter(r Ruler) LogBackend
type TemplateSetup ¶
type TestStruct ¶
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) 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