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 ¶
- Variables
- func AddAppender(appender logapi.Appender, lines []string)
- func AddDBAppender(driver, spec string, table string, lines []string)
- func GetAppenders() map[string]logapi.Appender
- func GetLevelColorMsg(level string, v ...interface{}) string
- func GetLevelLabel(level Level) string
- func InitConfig()
- func Insert(db *sql.DB, model LogTable) error
- func InspectLogger(logger *WrapLogger)
- func IsHasAppender(name string, lines []string) bool
- func IsWindows() bool
- func LoadAppenders(lines []string)
- func LoadConfig(location string) error
- func NewLogger(catalog string, callin int) logapi.Logger
- func ScanAddConsoleAppender(lines []string)
- func ScanAddDBAppender(lines []string)
- func ScanAddFileAppender(lines []string)
- func ScanConfigValue(scanKey string, lines []string) (string, bool)
- func SetAppenderLevel(appenderName, level string, catalogs ...string)
- func SetLevel(level string, catalogs ...string)
- func Sync(db *sql.DB, model LogTable) error
- func WriteLog(levelLabel, catalog string, callin int, args ...interface{})
- type BaseAppender
- type ConsoleAppender
- type DBAppender
- type FileAppender
- type Level
- type LogTable
- type WrapLogger
- func (l WrapLogger) CheckError(err error, msg ...interface{}) bool
- func (l WrapLogger) CheckErrorf(err error, msg string, args ...interface{}) bool
- func (l WrapLogger) CheckNil(v interface{}) bool
- func (l WrapLogger) Debug(args ...interface{})
- func (l WrapLogger) Debugf(format string, args ...interface{})
- func (l WrapLogger) Error(args ...interface{})
- func (l WrapLogger) Errorf(format string, args ...interface{})
- func (l WrapLogger) Info(args ...interface{})
- func (l WrapLogger) Infof(format string, args ...interface{})
- func (l *WrapLogger) Inspect()
- func (l WrapLogger) LoadConfig(location string)
- func (l WrapLogger) SetLevel(level string, catalog ...string)
- func (l WrapLogger) Trace(args ...interface{})
- func (l WrapLogger) Tracef(format string, args ...interface{})
- func (l WrapLogger) Warn(args ...interface{})
- func (l WrapLogger) Warnf(format string, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
var ConfigLocation = "log.conf"
Default config location.
var DB_LOG_TABLE = "common_wlog"
You can change it outside
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 AddDBAppender ¶
AddDBAppender
func GetLevelColorMsg ¶
func GetLevelLabel ¶
func InitConfig ¶
func InitConfig()
LoadDefaultConfig loads logger configuations. Privilege sequence: - ConfigLocation specification - log.conf - conf/log.conf - /etc/mlog/log.conf
func ScanAddConsoleAppender ¶
func ScanAddConsoleAppender(lines []string)
func ScanConfigValue ¶
ScanConfigValue
func SetAppenderLevel ¶
SetAppenderLevel
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
}
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
type FileAppender ¶
type FileAppender struct { *BaseAppender Location string }
func NewFileAppender ¶
func NewFileAppender(location string) *FileAppender
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
type WrapLogger ¶
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) SetLevel ¶
func (l WrapLogger) SetLevel(level string, catalog ...string)
SetLevel .