mini-logger: github.com/snail007/mini-logger Index | Files | Directories

package logger

import "github.com/snail007/mini-logger"

Index

Package Files

logger.go

Constants

const (
    DebugLevel uint8 = 1
    InfoLevel  uint8 = 1 << 1
    WarnLevel  uint8 = 1 << 2
    ErrorLevel uint8 = 1 << 3
    FatalLevel uint8 = 1 << 4
    AllLevels  uint8 = byte(DebugLevel | InfoLevel | WarnLevel | ErrorLevel | FatalLevel)
)

func Flush Uses

func Flush()

Flush wait for process all left entry

type Entry Uses

type Entry struct {
    Content               string
    Timestamp             int64
    Milliseconds          int64
    TimestampMilliseconds int64
    Level                 uint8
    LevelString           string
    Fields                map[string]string
    FieldsString          string
}

type Fields Uses

type Fields map[string]string

type Logger Uses

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

func (*Logger) AddWriter Uses

func (l *Logger) AddWriter(writer Writer, levels byte) MiniLogger

func (*Logger) Debug Uses

func (l *Logger) Debug(v ...interface{}) MiniLogger

func (*Logger) Debugf Uses

func (l *Logger) Debugf(format string, v ...interface{}) MiniLogger

func (*Logger) Debugln Uses

func (l *Logger) Debugln(v ...interface{}) MiniLogger

func (*Logger) Error Uses

func (l *Logger) Error(v ...interface{}) MiniLogger

func (*Logger) Errorf Uses

func (l *Logger) Errorf(format string, v ...interface{}) MiniLogger

func (*Logger) Errorln Uses

func (l *Logger) Errorln(v ...interface{}) MiniLogger

func (*Logger) Fatal Uses

func (l *Logger) Fatal(v ...interface{})

func (*Logger) Fatalf Uses

func (l *Logger) Fatalf(format string, v ...interface{})

func (*Logger) Fatalln Uses

func (l *Logger) Fatalln(v ...interface{})

func (*Logger) Info Uses

func (l *Logger) Info(v ...interface{}) MiniLogger

func (*Logger) Infof Uses

func (l *Logger) Infof(format string, v ...interface{}) MiniLogger

func (*Logger) Infoln Uses

func (l *Logger) Infoln(v ...interface{}) MiniLogger

func (*Logger) Safe Uses

func (l *Logger) Safe() MiniLogger

Safe : if you call Safe(), each message can be processed immediately, but this mode may be has lower performance,beacuse of logger must wait for all writers process done with each messsage. note: if you do logging before call os.Exit(), you had better to call Safe() before call os.Exit(). you call func Safe() or Unsafe() in any where any time to switch safe mode.

func (*Logger) Unsafe Uses

func (l *Logger) Unsafe() MiniLogger

func (*Logger) Warn Uses

func (l *Logger) Warn(v ...interface{}) MiniLogger

func (*Logger) Warnf Uses

func (l *Logger) Warnf(format string, v ...interface{}) MiniLogger

func (*Logger) Warnln Uses

func (l *Logger) Warnln(v ...interface{}) MiniLogger

func (*Logger) With Uses

func (l *Logger) With(fields Fields) MiniLogger

With return a new MiniLogger,which it's modeSafe inited same as caller MiniLogger, and revecived levels same as caller MiniLogger, and set it's fields. you can use it as a standard MiniLogger.

type MiniLogger Uses

type MiniLogger interface {
    Debug(v ...interface{}) MiniLogger
    Info(v ...interface{}) MiniLogger
    Warn(v ...interface{}) MiniLogger
    Error(v ...interface{}) MiniLogger
    Fatal(v ...interface{})
    Debugf(format string, v ...interface{}) MiniLogger
    Infof(format string, v ...interface{}) MiniLogger
    Warnf(format string, v ...interface{}) MiniLogger
    Errorf(format string, v ...interface{}) MiniLogger
    Fatalf(format string, v ...interface{})
    Debugln(v ...interface{}) MiniLogger
    Infoln(v ...interface{}) MiniLogger
    Warnln(v ...interface{}) MiniLogger
    Errorln(v ...interface{}) MiniLogger
    Fatalln(v ...interface{})
    AddWriter(w Writer, levels uint8) MiniLogger
    Safe() MiniLogger
    Unsafe() MiniLogger
    With(fields Fields) MiniLogger
}

func New Uses

func New(modeSafe bool, fields Fields) MiniLogger

New returns a new logger modeSafe when false : must call logger.Flush() in main defer if not do that, may be lost message,but this mode has a highest performance when true : each message can be processed , but this mode may be has a little lower performance beacuse of logger must wait for all writers process done with each messsage. note: if you do logging before call os.Exit(), you had better to set safeMode to true before call os.Exit(). fields same as With()'s args,more about fields to see With().

type WrappedWriter Uses

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

type Writer Uses

type Writer interface {
    Write(e Entry)
    Init() error
}

Directories

PathSynopsis
writers/console
writers/files

Package logger imports 5 packages (graph) and is imported by 3 packages. Updated 2018-06-24. Refresh now. Tools for package owners.