log

package
v0.0.0-...-6af97ad Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

This source you can use!

This source you can use!

Package log

This source you can use!

This source you can use!

This source you can use!

Index

Constants

View Source
const (
	NOSET  = 0
	NO     = 110
	PANIC  = 120
	ERROR  = 130
	WARN   = 140
	NOTICE = 150
	LOG    = 160
	DEBUG  = 170
	ALL    = 180
)

Variables

View Source
var (
	DefaultLowCallpath      = 0
	DefaultAppenderCallpath = 2
	DefaultLoggerCallpath   = 3
)
View Source
var LogLevelMap map[string]int = map[string]int{
	"NO":     NO,
	"DEBUG":  DEBUG,
	"WARN":   WARN,
	"NOTICE": NOTICE,
	"LOG":    LOG,
	"ERROR":  ERROR,
	"PANIC":  PANIC,
	"ALL":    ALL,
}
View Source
var UseShortFile bool

Functions

func Debug

func Debug(args ...interface{})

func Debugf

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

func Error

func Error(args ...interface{})

func Errorf

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

func Init

func Init(jsconf string) (err error)

func InitConf

func InitConf(cfg *Config) (err error)

func IsAll

func IsAll() bool

func IsDebug

func IsDebug() bool

func IsError

func IsError() bool

func IsInfo

func IsInfo() bool

func IsNotice

func IsNotice() bool

func IsWarn

func IsWarn() bool

func Log

func Log(args ...interface{})

func Logf

func Logf(format string, args ...interface{})

func New

func New(filename string)

func Notice

func Notice(args ...interface{})

func Noticef

func Noticef(format string, args ...interface{})

func SetRootAppender

func SetRootAppender(appenders ...Appender)

func SetRootFileAppender

func SetRootFileAppender(fileName string)

func SetRootLevel

func SetRootLevel(l int)

func SetRootOnlyLevel

func SetRootOnlyLevel(ls ...int)

func SetRootSeparationAppender

func SetRootSeparationAppender(fileName string)

func UseRoot

func UseRoot(name string) error

func Warn

func Warn(args ...interface{})

func Warnf

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

Types

type Appender

type Appender interface {
	Log(extendCallpath int, level string, args ...interface{})
	Logln(extendCallpath int, level string, args ...interface{})
	Logf(extendCallpath int, level string, format string, args ...interface{})
	SetCallpath(int)
}

日志的输出接口

type Config

type Config struct {
	UseShortFile bool
	Appenders    map[string]struct {
		Type   string
		Target string
	}
	Loggers map[string]ConfigLogger
	Root    ConfigLogger
	Roots   map[string]ConfigLogger
	// contains filtered or unexported fields
}

日志的配置,可以通过配置json来配置日志

func LoadConf

func LoadConf(jsConf string) (cfg *Config, err error)

加载json配置

func (*Config) BuildAppenders

func (self *Config) BuildAppenders() map[string]Appender

实例化配置中的appender

func (*Config) BuildLoggers

func (self *Config) BuildLoggers() []*LoggerConf

func (Config) RootLogger

func (self Config) RootLogger() *LoggerConf

func (Config) RootsLogger

func (self Config) RootsLogger() map[string]*LoggerConf

func (Config) Verify

func (self Config) Verify() error

type ConfigLogger

type ConfigLogger struct {
	Appenders []string
	Level     interface{}
}

type ConsoleAppender

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

func NewConsoleAppender

func NewConsoleAppender(name string) *ConsoleAppender

func (ConsoleAppender) Log

func (l ConsoleAppender) Log(extendCallpath int, level string, args ...interface{})

func (ConsoleAppender) Logf

func (l ConsoleAppender) Logf(extendCallpath int, level string, format string, args ...interface{})

func (ConsoleAppender) Logln

func (l ConsoleAppender) Logln(extendCallpath int, level string, args ...interface{})

func (ConsoleAppender) SetCallpath

func (l ConsoleAppender) SetCallpath(level int)

type DailyAppender

type DailyAppender struct {
	*FileAppender
	// contains filtered or unexported fields
}

func NewDailyAppender

func NewDailyAppender(name, fileName string) *DailyAppender

func NewDailyAppenderEx

func NewDailyAppenderEx(name, fileName, extension string) *DailyAppender

func (DailyAppender) SetCallpath

func (l DailyAppender) SetCallpath(level int)

type FileAppender

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

func NewFileAppender

func NewFileAppender(name string, fileName string) *FileAppender

func (*FileAppender) Log

func (l *FileAppender) Log(extendCallpath int, level string, args ...interface{})

func (*FileAppender) Logf

func (l *FileAppender) Logf(extendCallpath int, level string, format string, args ...interface{})

func (*FileAppender) Logln

func (l *FileAppender) Logln(extendCallpath int, level string, args ...interface{})

func (FileAppender) SetCallpath

func (l FileAppender) SetCallpath(level int)

type LevelSeparationAppender

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

把不同等级的信息打印到不同的Appender中

func NewLevelSeparationAppender

func NewLevelSeparationAppender(name string) *LevelSeparationAppender

func NewLevelSeparationDailyAppender

func NewLevelSeparationDailyAppender(name string, fileName string) *LevelSeparationAppender

func (*LevelSeparationAppender) Log

func (this *LevelSeparationAppender) Log(extendCallpath int, level string, args ...interface{})

func (*LevelSeparationAppender) Logf

func (this *LevelSeparationAppender) Logf(extendCallpath int, level string, format string, args ...interface{})

func (*LevelSeparationAppender) Logln

func (this *LevelSeparationAppender) Logln(extendCallpath int, level string, args ...interface{})

func (*LevelSeparationAppender) SetCallpath

func (this *LevelSeparationAppender) SetCallpath(level int)

func (*LevelSeparationAppender) SetLevelAppender

func (this *LevelSeparationAppender) SetLevelAppender(level string, appender Appender)

type Logger

type Logger struct {
	*LoggerConf
	Callpath int // 不放在LoggerConf中,因为同一个名称的Logger实例,Conf相同,可能被封装的层次不同,用Callpath的不同
}

日志类

func Get

func Get(name string) *Logger

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

func (*Logger) Debugf

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

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

func (*Logger) Errorf

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

func (*Logger) IsAll

func (l *Logger) IsAll() bool

func (*Logger) IsDebug

func (l *Logger) IsDebug() bool

func (*Logger) IsError

func (l *Logger) IsError() bool

func (*Logger) IsInfo

func (l *Logger) IsInfo() bool

func (*Logger) IsLogLevel

func (l *Logger) IsLogLevel(level int) bool

func (*Logger) IsNotice

func (l *Logger) IsNotice() bool

func (*Logger) IsWarn

func (l *Logger) IsWarn() bool

func (*Logger) Log

func (l *Logger) Log(args ...interface{})

func (*Logger) Logf

func (l *Logger) Logf(format string, args ...interface{})

func (*Logger) Notice

func (l *Logger) Notice(args ...interface{})

func (*Logger) Noticef

func (l *Logger) Noticef(format string, args ...interface{})

func (*Logger) Panic

func (l *Logger) Panic(args ...interface{})

func (*Logger) Panicf

func (l *Logger) Panicf(format string, args ...interface{})

func (*Logger) SetCallpath

func (l *Logger) SetCallpath(callpath int)

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

func (*Logger) Warnf

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

type LoggerConf

type LoggerConf struct {
	Name      string
	Levels    map[int]bool
	Appenders []Appender
}

logger的配置类

func (*LoggerConf) SetAppender

func (self *LoggerConf) SetAppender(appenders ...Appender)

func (*LoggerConf) SetLevel

func (self *LoggerConf) SetLevel(level int)

func (*LoggerConf) SetOnlyLevels

func (self *LoggerConf) SetOnlyLevels(levels ...int)

type LoggerManager

type LoggerManager struct {
	*Tree
	// contains filtered or unexported fields
}

日志的管理类,用于加载配置,返回正确的logger

func CurLoggerMananger

func CurLoggerMananger() (cfg *LoggerManager)

func NewLoggerManager

func NewLoggerManager(root *LoggerConf) *LoggerManager

func NewLoggerManagerWithConf

func NewLoggerManagerWithConf(cfg *Config) (*LoggerManager, error)

func NewLoggerManagerWithJsconf

func NewLoggerManagerWithJsconf(jsConf string) (*LoggerManager, error)

func (*LoggerManager) Logger

func (self *LoggerManager) Logger(name string) (logger *Logger)

func (*LoggerManager) SetLogger

func (self *LoggerManager) SetLogger(logger *Logger)

func (*LoggerManager) SetRootAppender

func (self *LoggerManager) SetRootAppender(appenders ...Appender)

func (*LoggerManager) SetRootLevel

func (self *LoggerManager) SetRootLevel(l int)

func (*LoggerManager) SetRootOnlyLevel

func (self *LoggerManager) SetRootOnlyLevel(ls ...int)

func (*LoggerManager) UpdateConf

func (self *LoggerManager) UpdateConf(cfg *Config) error

func (*LoggerManager) UseRoot

func (self *LoggerManager) UseRoot(name string) (err error)

type Tree

type Tree struct {
	Root *node
}

日志配置树,用于可以获取可继承的日志配置 根节点为"" 日志配置在树中的节点与名称有关,如a/b/c则是 ""->a->b->c 的树

func NewTree

func NewTree(root *LoggerConf) *Tree

Directories

Path Synopsis
Package log implements a simple logging package.
Package log implements a simple logging package.

Jump to

Keyboard shortcuts

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