golog: github.com/umisama/golog Index | Files

package log

import "github.com/umisama/golog"

Index

Package Files

log.go

Constants

const (
    LogLevel_Debug    = LogLevel(iota) // output all
    LogLevel_Info                      // outuut Info or greater.
    LogLevel_Warn                      // output Warn and Critical
    LogLevel_Critical                  // output Critical only
    LogLevel_Silent                    // no output
)

LogLevel_* reprecents supporting log level. priority : Debug < Info < Warn < Critical LogLevel_Silent ignores all log levels.

const (
    LOG_FORMAT_SIMPLE   = "{{.Time}} : {{.Message}} \n"
    LOG_FORMAT_STANDARD = "{{.Time}} {{.ShortFileName}}:({{.LineNumber}}) : {{.Message}}\n"
    LOG_FORMAT_POWERFUL = "{{.Time}} {{.ShortFileName}}:{{.LineNumber}}({{.ShortFuncName}}) : {{.Message}}\n"
)

LOG_FORMAT_* is example format string(with text/template)

const (
    TIME_FORMAT_DATE     = "2006/1/2"
    TIME_FORMAT_SEC      = "2006/1/2 15:04:05"
    TIME_FORMAT_MILLISEC = "2006/1/2 15:04:05.000"
)

TIME_FORMAT_* is example format string(with time)

type LogLevel Uses

type LogLevel int

LogLevel reprecents log priority.

func (LogLevel) String Uses

func (l LogLevel) String() string

type LogTemplate Uses

type LogTemplate struct {
    Time          string
    FuncName      string
    ShortFuncName string
    FileName      string
    ShortFileName string
    Goroutine     string
    LineNumber    string
    Message       string
}

LogTemplate is template object on LOG_FORMAT_* this object public for documentation.

type Logger Uses

type Logger interface {
    // Debug output log by Debug level(1)
    Debug(a ...interface{})

    // Debugf output log by Debug level(1) with format string.
    Debugf(msg_fmt string, a ...interface{})

    // Info output log by Info level(2)
    Info(a ...interface{})

    // Infof output log by Info level(2) with format string.
    Infof(msg_fmt string, a ...interface{})

    // Warn output log by Warn level(3)
    Warn(a ...interface{})

    // Warnf output log by Warn level(3) with format string.
    Warnf(msg_fmt string, a ...interface{})

    // Critical output log by Critical level(4)
    Critical(a ...interface{})

    // Criticalf output log by Critical level(4) with format string.
    Criticalf(msg_fmt string, a ...interface{})
}

func NewLogger Uses

func NewLogger(dst io.Writer, time_fmt string, log_fmt string, level LogLevel) (l Logger, err error)

NewLogger returns Logger that outputs to dst with level. log will be formated by time_fmt and log_fmt.

Package log imports 7 packages (graph) and is imported by 4 packages. Updated 2016-07-26. Refresh now. Tools for package owners.