Documentation ¶
Index ¶
- Constants
- func AsString(val interface{}) (string, bool)
- func AsStringQ(val interface{}) string
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Debugln(args ...interface{})
- func Debugw(msg string, keyVals ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Errorln(args ...interface{})
- func Errorw(msg string, keyVals ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Fatalln(args ...interface{})
- func Fatalw(msg string, keyVals ...interface{})
- func FieldsToMap(keyVals []interface{}) map[string]interface{}
- func HasLevel(lv Level) bool
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func Infoln(args ...interface{})
- func Infow(msg string, keyVals ...interface{})
- func LevelFixedString(lv Level) string
- func LevelsCount() int
- func MustUse(name string, w io.Writer, l Level)
- func Panic(args ...interface{})
- func Panicf(format string, args ...interface{})
- func Panicln(args ...interface{})
- func Panicw(msg string, keyVals ...interface{})
- func Print(args ...interface{})
- func Printf(format string, args ...interface{})
- func Println(args ...interface{})
- func Printw(msg string, keyVals ...interface{})
- func Register(name string, constructor Constructor)
- func SeparateFields(keyVals []interface{}) ([]string, []interface{})
- func SetLevel(lv Level)
- func SimpleFormatter(msg string, keyVals []interface{}, sep string) string
- func Trace(args ...interface{})
- func Tracef(format string, args ...interface{})
- func Traceln(args ...interface{})
- func Tracew(msg string, keyVals ...interface{})
- func Use(name string, w io.Writer, l Level) error
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- func Warnln(args ...interface{})
- func Warnw(msg string, keyVals ...interface{})
- type Constructor
- type Level
- type LevelLoggerBase
- type Logger
- type Options
- func (op Options) Get(key string, def interface{}) interface{}
- func (op Options) GetBool(key string, def bool) bool
- func (op Options) GetInt(key string, def int) int
- func (op Options) GetMap(key string) map[string]interface{}
- func (op Options) GetOptions(key string) Options
- func (op Options) GetString(key string, def string) string
Constants ¶
const AllLevel = PanicLevel | FatalLevel | ErrorLevel | WarnLevel | InfoLevel | DebugLevel | TraceLevel
AllLevel contains all log level
const DiscardLoggerName = "discard"
Name of discard logger
const StdLoggerName = "stdlog"
Name of the standard logger
Variables ¶
This section is empty.
Functions ¶
func AsStringQ ¶
func AsStringQ(val interface{}) string
AsStringQ convert value into string. Value will be double-qouted if value is string/time/stringer
func FieldsToMap ¶
func FieldsToMap(keyVals []interface{}) map[string]interface{}
FieldsToMap convert key-value array to map[string]interface{}
func LevelFixedString ¶
LevelFixedString return fixed string for given level
func SeparateFields ¶
func SeparateFields(keyVals []interface{}) ([]string, []interface{})
SeparateFields into array of keys and array of values
func SimpleFormatter ¶
Simpleformatter return simple key-value formatter, separated with `sep`
Types ¶
type Constructor ¶
type Constructor interface { New(w io.Writer, level Level) (Logger, error) NewWithOptions(w io.Writer, level Level, op Options) (Logger, error) }
Constructor for reader creator
func ConstructorFor ¶
func ConstructorFor(name string) (Constructor, bool)
ConstructorFor return sql query for given name
type Level ¶
type Level uint32
Level of the log
const ( PanicLevel Level = 1 << iota FatalLevel ErrorLevel WarnLevel InfoLevel DebugLevel TraceLevel )
Logger level
func (Level) MarshalText ¶
MarshalText return level as byte string
func (*Level) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type LevelLoggerBase ¶
type LevelLoggerBase struct {
// contains filtered or unexported fields
}
LevelLogger base
func NewLevelLoggerBase ¶
func NewLevelLoggerBase(lv Level) *LevelLoggerBase
NewLevelLoggerBase return new instance of level logger base
func (*LevelLoggerBase) HasLevel ¶
func (b *LevelLoggerBase) HasLevel(lv Level) bool
HasLevel return current logger level
func (*LevelLoggerBase) SetLevel ¶
func (b *LevelLoggerBase) SetLevel(lv Level)
SetLevel set logger level using flags
type Logger ¶
type Logger interface { HasLevel(lv Level) bool SetLevel(lv Level) Trace(args ...interface{}) Debug(args ...interface{}) Print(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) Fatal(args ...interface{}) Panic(args ...interface{}) Traceln(args ...interface{}) Debugln(args ...interface{}) Println(args ...interface{}) Infoln(args ...interface{}) Warnln(args ...interface{}) Errorln(args ...interface{}) Fatalln(args ...interface{}) Panicln(args ...interface{}) Tracef(format string, args ...interface{}) Debugf(format string, args ...interface{}) Printf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) Panicf(format string, args ...interface{}) Tracew(msg string, keyVals ...interface{}) Debugw(msg string, keyVals ...interface{}) Printw(msg string, keyVals ...interface{}) Infow(msg string, keyVals ...interface{}) Warnw(msg string, keyVals ...interface{}) Errorw(msg string, keyVals ...interface{}) Fatalw(msg string, keyVals ...interface{}) Panicw(msg string, keyVals ...interface{}) }
Loger interface
var ( UnknownFieldName = "@logfield" DefaultLogger Logger = discardL )
Unknown field name and default logger
var Discard Logger = &discardLogger{LevelLoggerBase: LevelLoggerBase{level: AllLevel}}
Global discard logger
func NewDiscardLogger ¶
NewDiscardLogger creates discard logger
func NewStdLogger ¶
NewStdLogger creates new logger with given parameters
type Options ¶
type Options map[string]interface{}
Options stores additional log configuration
func (Options) GetOptions ¶ added in v0.2.0
GetOptions get value as map[string]interface{}