log: github.com/lrita/log Index | Files

package log

import "github.com/lrita/log"

Index

Package Files

aio.go appender.go fadvise_linux.go global.go level.go logger.go

Variables

var (
    HourlySuffix = ".20060102-15"
    DailySuffix  = ".20060102"
)
var ExitOnFatal = true

ExitOnFatal decides whether or not to exit when fatal log printing.

var LevelsToString = map[Level]string{
    TRACE: "TRACE",
    DEBUG: "DEBUG",
    INFO:  "INFO",
    WARN:  "WARN",
    ERROR: "ERROR",
    FATAL: "FATAL",
}
var StringToLevels = map[string]Level{
    "TRACE": TRACE,
    "DEBUG": DEBUG,
    "INFO":  INFO,
    "WARN":  WARN,
    "ERROR": ERROR,
    "FATAL": FATAL,
}

func Debug Uses

func Debug(v ...interface{})

func Debugf Uses

func Debugf(fmt string, v ...interface{})

func Error Uses

func Error(v ...interface{})

func Errorf Uses

func Errorf(fmt string, v ...interface{})

func Fatal Uses

func Fatal(v ...interface{})

func Fatalf Uses

func Fatalf(fmt string, v ...interface{})

func Info Uses

func Info(v ...interface{})

func Infof Uses

func Infof(fmt string, v ...interface{})

func IsDebugEnabled Uses

func IsDebugEnabled() bool

IsDebugEnabled indicates whether debug level is enabled

func SetAppender Uses

func SetAppender(appender Appender, levels ...Level)

SetAppender set append for global logger

func SetCallDepth Uses

func SetCallDepth(d int)

SetCallDepth set callee stack depth

func SetFormat Uses

func SetFormat(fmt string, levels ...Level)

SetFormat set format-string for global logger

func SetLevel Uses

func SetLevel(level Level)

SetLevel log level for global logger

func SetRatelimit Uses

func SetRatelimit(limit int64, levels ...Level)

SetRatelimit set log rate limit for global logger

func Trace Uses

func Trace(v ...interface{})

func Tracef Uses

func Tracef(fmt string, v ...interface{})

func Warn Uses

func Warn(v ...interface{})

func Warnf Uses

func Warnf(fmt string, v ...interface{})

type AIO Uses

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

AIO implements buffering asynchronous Writer for an io.Writer object. Which can reduce the latency spike of api occurrence by disk/system latency. If an error occurs writing to a Writer, no more data will be accepted and all subsequent writes, and Flush, will return the error. After all data has been written, the client should call the Flush method to guarantee all data has been forwarded to the underlying io.Writer.

func NewAIO Uses

func NewAIO(w io.Writer, size int) *AIO

NewAIO returns a new Writer whose buffer has at least the specified size. If the argument io.Writer is already a Writer with large enough size, it returns the underlying Writer.

func (*AIO) Available Uses

func (a *AIO) Available() int

Available returns how many bytes are unused in the buffer.

func (*AIO) Buffered Uses

func (a *AIO) Buffered() int

Buffered returns the number of bytes that have been written into the current buffer.

func (*AIO) Flush Uses

func (a *AIO) Flush() error

Flush writes any buffered data to the underlying io.Writer.

func (*AIO) Reset Uses

func (a *AIO) Reset(w io.Writer)

Reset discards any unflushed buffered data, clears any error, and resets b to write its output to w.

func (*AIO) Write Uses

func (a *AIO) Write(p []byte) (nn int, err error)

Write writes the contents of p into the buffer. It returns the number of bytes written. If nn < len(p), it also returns an error explaining why the write is short.

type Appender Uses

type Appender interface {
    // Output will be invoked by Logger. The Logger input a formatted data
    // to the appender using Output. And the data is only valid during the
    // Output invoking, if you want do something async with data, you need
    // copy it yourself.
    Output(level Level, t time.Time, data []byte)
}

func NewConsoleAppender Uses

func NewConsoleAppender() Appender

type Flusher Uses

type Flusher interface {
    Flush() error
}

type Level Uses

type Level int8
const (
    FATAL Level = iota
    ERROR
    WARN
    INFO
    DEBUG
    TRACE
)

type Logger Uses

type Logger interface {
    // New return a new log handler which inherit its appender and formater
    New(name string) Logger
    // Level return the logger current log-level
    Level() Level
    // SetLevel set the logger current log-level
    SetLevel(level Level)
    // SetAppender the given log-level to use the special appender.
    // If non-given log-level, all log-level use it
    SetAppender(appender Appender, levels ...Level)
    // SetRatelimit the give limit(QPS) rate to the logger.
    SetRatelimit(limit int64, levels ...Level)
    // SetFormat the given log-level to use the special format.
    // If non-given log-level, all log-level use it
    // fmt is a pattern-string, default is "%F %T [%l] %m"
    // %m => the log message and its arguments formatted with `fmt.Sprintf` or `fmt.Sprint`
    // %l => the log-level string
    // %C => the caller with full file path
    // %c => the caller with short file path
    // %L => the line number of caller
    // %% => '%'
    // %n => '\n'
    // %F => the date formatted like "2006-01-02"
    // %D => the date formatted like "01/02/06"
    // %T => the time formatted like 24h style "15:04:05"
    // %a => the short name of weekday like "Mon"
    // %A => the full name of weekday like "Monday"
    // %b => the short name of month like "Jan"
    // %B => the full name of month like "January"
    // %d => the datetime formatted like RFC3339 "2006-01-02T15:04:05Z07:00"
    SetFormat(fmt string, levels ...Level)
    // SetCallDepth set callee stack depth
    SetCallDepth(d int)
    // IsDebugEnabled indicates whether debug level is enabled
    IsDebugEnabled() bool

    Fatal(v ...interface{})
    Error(v ...interface{})
    Info(v ...interface{})
    Warn(v ...interface{})
    Debug(v ...interface{})
    Trace(v ...interface{})

    Fatalf(fmt string, v ...interface{})
    Errorf(fmt string, v ...interface{})
    Infof(fmt string, v ...interface{})
    Warnf(fmt string, v ...interface{})
    Debugf(fmt string, v ...interface{})
    Tracef(fmt string, v ...interface{})
}

func New Uses

func New(name string) Logger

New return a sub logger of global logger

type Reseter Uses

type Reseter interface {
    Reset(w io.Writer)
}

type RotateAppender Uses

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

func NewDailyRotateAppender Uses

func NewDailyRotateAppender(filename string) (*RotateAppender, error)

func NewDailyRotateBufAppender Uses

func NewDailyRotateBufAppender(filename string, bufsize int) (*RotateAppender, error)

func NewHourlyRotateAppender Uses

func NewHourlyRotateAppender(filename string) (*RotateAppender, error)

func NewHourlyRotateBufAppender Uses

func NewHourlyRotateBufAppender(filename string, bufsize int) (*RotateAppender, error)

func (*RotateAppender) Close Uses

func (a *RotateAppender) Close() error

func (*RotateAppender) Flush Uses

func (a *RotateAppender) Flush() error

func (*RotateAppender) Output Uses

func (a *RotateAppender) Output(_ Level, t time.Time, data []byte)

Package log imports 12 packages (graph). Updated 2019-03-19. Refresh now. Tools for package owners.