wlog

package
v0.0.0-...-670bf6b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2017 License: Apache-2.0, Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

wlog wrap log, provides Info Debug .. methods. and color output. depends on: github.com/agtorre/gocolorize now only can output to os.Stdout. TODO: add more append.

Index

Constants

This section is empty.

Variables

View Source
var ConfigLocation = "log.conf"

Default config location.

View Source
var DB_LOG_TABLE = "common_wlog"

You can change it outside

View Source
var (
	//Define the look/feel of the INFO logger
	//LogFormat = log.Ldate | log.Ltime | log.Llongfile
	LogFormat = log.Ldate | log.Ltime | log.Lmicroseconds | log.Llongfile
)

Functions

func AddAppender

func AddAppender(appender logapi.Appender, lines []string)

AddAppender

func AddDBAppender

func AddDBAppender(driver, spec string, table string, lines []string)

AddDBAppender

func GetAppenders

func GetAppenders() map[string]logapi.Appender

InitAppender

func GetLevelColorMsg

func GetLevelColorMsg(level string, v ...interface{}) string

func GetLevelLabel

func GetLevelLabel(level Level) string

func InitConfig

func InitConfig()

LoadDefaultConfig loads logger configuations. Privilege sequence: - ConfigLocation specification - log.conf - conf/log.conf - /etc/mlog/log.conf

func Insert

func Insert(db *sql.DB, model LogTable) error

func InspectLogger

func InspectLogger(logger *WrapLogger)

InspectLogger

func IsHasAppender

func IsHasAppender(name string, lines []string) bool

IsHasAppender

func IsWindows

func IsWindows() bool

IsWindows judge host os system.

func LoadAppenders

func LoadAppenders(lines []string)

LoadAppenders

func LoadConfig

func LoadConfig(location string) error

LoadConfig try to read config file.

func NewLogger

func NewLogger(catalog string, callin int) logapi.Logger

NewLogger returns logapi.Logger

func ScanAddConsoleAppender

func ScanAddConsoleAppender(lines []string)

func ScanAddDBAppender

func ScanAddDBAppender(lines []string)

ScanAddDBAppender

func ScanAddFileAppender

func ScanAddFileAppender(lines []string)

ScanAddFileAppender

func ScanConfigValue

func ScanConfigValue(scanKey string, lines []string) (string, bool)

ScanConfigValue

func SetAppenderLevel

func SetAppenderLevel(appenderName, level string, catalogs ...string)

SetAppenderLevel

func SetLevel

func SetLevel(level string, catalogs ...string)

SetLevel implements api

func Sync

func Sync(db *sql.DB, model LogTable) error

func WriteLog

func WriteLog(levelLabel, catalog string, callin int, args ...interface{})

WriteLog all log methods call this one.

Types

type BaseAppender

type BaseAppender struct {
	Name string
	// contains filtered or unexported fields
}

BaseAppender

func NewBaseAppender

func NewBaseAppender(name string) *BaseAppender

func (*BaseAppender) GetName

func (a *BaseAppender) GetName() string

func (*BaseAppender) Inspect

func (a *BaseAppender) Inspect(catalog string)

func (*BaseAppender) IsOutputLog

func (a *BaseAppender) IsOutputLog(label, catalog string) bool

func (*BaseAppender) ScanConfigLevel

func (a *BaseAppender) ScanConfigLevel(lines []string)

ScanConfigLevel

func (*BaseAppender) SetLevel

func (a *BaseAppender) SetLevel(levelLabel string, catalogs ...string)

Appender SetLevel

type ConsoleAppender

type ConsoleAppender struct {
	*BaseAppender
}

func NewConsoleAppender

func NewConsoleAppender() *ConsoleAppender

NewConsoleAppender

func (ConsoleAppender) WriteLog

func (a ConsoleAppender) WriteLog(level string, catalog string, callin int, v ...interface{})

WriteLog implements Appender output example: [INFO] mabetle: message.

type DBAppender

type DBAppender struct {
	Sql *sql.DB
	*BaseAppender
	// contains filtered or unexported fields
}

func NewDBAppender

func NewDBAppender(driver, spec, table string) (*DBAppender, error)

NewDBAppender create new db appender

func (*DBAppender) WriteLog

func (a *DBAppender) WriteLog(level string, catalog string, callin int, v ...interface{})

WriteLog implements for api.LogWriter

type FileAppender

type FileAppender struct {
	*BaseAppender
	Location string
}

func NewFileAppender

func NewFileAppender(location string) *FileAppender

func (*FileAppender) WriteLog

func (a *FileAppender) WriteLog(level string, catalog string, callin int, v ...interface{})

WriteLog implements Appender output example: [INFO] mabetle: message.

type Level

type Level int
const (
	LevelUknown Level = iota
	LevelTrace
	LevelDebug
	LevelInfo
	LevelWarn
	LevelError
)

func GetLabelLevel

func GetLabelLevel(label string) Level

GetLabelLevel same as GetStringLevel

func GetStringLevel

func GetStringLevel(str string) Level

type LogTable

type LogTable struct {
	Id         int64  ``
	Level      string `xorm:"varchar(10)"`
	Source     string `xorm:"varchr(500)"`
	Line       int
	Catalog    string    `xorm:"varchar(500)"`
	Message    string    `xorm:"varchar(1000)"`
	CreateTime time.Time `xorm:"created"`
}

store in database

func (LogTable) TableName

func (m LogTable) TableName() string

TableName

type WrapLogger

type WrapLogger struct {
	Catalog string
	Callin  int
}

WrapLogger .

func NewWrapLogger

func NewWrapLogger(catalog string, callin int) *WrapLogger

NewWrapLogger create WrapLogger instanse. WrapLogger implemnts api.Logger

func (WrapLogger) CheckError

func (l WrapLogger) CheckError(err error, msg ...interface{}) bool

CheckError check error and log it. if err not nil return true.

func (WrapLogger) CheckErrorf

func (l WrapLogger) CheckErrorf(err error, msg string, args ...interface{}) bool

CheckErrorf check errors

func (WrapLogger) CheckNil

func (l WrapLogger) CheckNil(v interface{}) bool

CheckNil used in if nil == v statement.

func (WrapLogger) Debug

func (l WrapLogger) Debug(args ...interface{})

Debug .

func (WrapLogger) Debugf

func (l WrapLogger) Debugf(format string, args ...interface{})

Debugf .

func (WrapLogger) Error

func (l WrapLogger) Error(args ...interface{})

Error .

func (WrapLogger) Errorf

func (l WrapLogger) Errorf(format string, args ...interface{})

Errorf .

func (WrapLogger) Info

func (l WrapLogger) Info(args ...interface{})

Info .

func (WrapLogger) Infof

func (l WrapLogger) Infof(format string, args ...interface{})

Infof .

func (*WrapLogger) Inspect

func (l *WrapLogger) Inspect()

Inspect

func (WrapLogger) LoadConfig

func (l WrapLogger) LoadConfig(location string)

LoadConfig .

func (WrapLogger) SetLevel

func (l WrapLogger) SetLevel(level string, catalog ...string)

SetLevel .

func (WrapLogger) Trace

func (l WrapLogger) Trace(args ...interface{})

Trace .

func (WrapLogger) Tracef

func (l WrapLogger) Tracef(format string, args ...interface{})

Tracef .

func (WrapLogger) Warn

func (l WrapLogger) Warn(args ...interface{})

Warn .

func (WrapLogger) Warnf

func (l WrapLogger) Warnf(format string, args ...interface{})

Warnf .

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL