Documentation ¶
Index ¶
- Constants
- Variables
- type Logging
- func Debug(v ...interface{}) *Logging
- func Error(v ...interface{}) *Logging
- func Fatal(v ...interface{}) *Logging
- func GetStaticLogger() *Logging
- func Info(v ...interface{}) *Logging
- func NewLogger() (log *Logging)
- func SetConsole(on bool) *Logging
- func SetFormat(format _FORMAT) *Logging
- func SetGzipOn(is bool) (l *Logging)
- func SetLevel(level _LEVEL) *Logging
- func SetRollingByTime(fileDir, fileName string, mode _MODE_TIME) (l *Logging, err error)
- func SetRollingDaily(fileDir, fileName string) (l *Logging, err error)
- func SetRollingFile(fileDir, fileName string, maxFileSize int64, unit _UNIT) (l *Logging, err error)
- func SetRollingFileLoop(fileDir, fileName string, maxFileSize int64, unit _UNIT, maxFileNum int) (l *Logging, err error)
- func Warn(v ...interface{}) *Logging
- func (t *Logging) Debug(v ...interface{}) *Logging
- func (t *Logging) Error(v ...interface{}) *Logging
- func (t *Logging) Fatal(v ...interface{}) *Logging
- func (t *Logging) Info(v ...interface{}) *Logging
- func (t *Logging) SetConsole(_isConsole bool) *Logging
- func (t *Logging) SetFormat(format _FORMAT) *Logging
- func (t *Logging) SetGzipOn(is bool) *Logging
- func (t *Logging) SetLevel(level _LEVEL) *Logging
- func (t *Logging) SetRollingByTime(fileDir, fileName string, mode _MODE_TIME) (l *Logging, err error)
- func (t *Logging) SetRollingDaily(fileDir, fileName string) (l *Logging, err error)
- func (t *Logging) SetRollingFile(fileDir, fileName string, maxFileSize int64, unit _UNIT) (l *Logging, err error)
- func (t *Logging) SetRollingFileLoop(fileDir, fileName string, maxFileSize int64, unit _UNIT, maxFileNum int) (l *Logging, err error)
- func (t *Logging) Warn(v ...interface{}) *Logging
- func (t *Logging) Write(bs []byte) (n int, err error)
- func (t *Logging) WriteBin(bs []byte) (bakfn string, err error)
Constants ¶
const ( KB _UNIT = 1 << (iota * 10) MB GB TB )
const ( MODE_HOUR _MODE_TIME = 1 MODE_DAY _MODE_TIME = 2 MODE_MONTH _MODE_TIME = 3 )
const ( /*无其他格式,只打印日志内容*/ /*no format, Only log content is printed*/ FORMAT_NANO _FORMAT = 0 /*长文件名(文件绝对路径)及行数*/ /*full file name and line number*/ FORMAT_LONGFILENAME = _FORMAT(8) /*短文件名及行数*/ /*final file name element and line number*/ FORMAT_SHORTFILENAME = _FORMAT(16) /*日期时间精确到天*/ /*the date in the local time zone: 2009/01/23*/ FORMAT_DATE = _FORMAT(1) /*时间精确到秒*/ /*the time in the local time zone: 01:23:23*/ FORMAT_TIME = _FORMAT(2) /*时间精确到微秒*/ /*microsecond resolution: 01:23:23.123123.*/ FORMAT_MICROSECNDS = _FORMAT(4) )
const ( /*日志级别:ALL 最低级别*/ /*Log level: LEVEL_ALL is the lowest level,If the log level is this level, logs of other levels can be printed*/ LEVEL_ALL _LEVEL = iota /*日志级别:DEBUG 小于INFO*/ /*Log level: ALL<DEBUG<INFO*/ LEVEL_DEBUG /*日志级别:INFO 小于 WARN*/ /*Log level: DEBUG<INFO<WARN*/ LEVEL_INFO /*日志级别:WARN 小于 ERROR*/ /*Log level: INFO<WARN<ERROR*/ LEVEL_WARN /*日志级别:ERROR 小于 FATAL*/ /*Log level: WARN<ERROR<FATAL*/ LEVEL_ERROR /*日志级别:FATAL 小于 OFF*/ /*Log level: ERROR<FATAL<OFF*/ LEVEL_FATAL /*日志级别:off 不打印任何日志*/ /*Log level: LEVEL_OFF means none of the logs can be printed*/ LEVEL_OFF )
const (
VERSION string = "0.0.2"
)
Variables ¶
var DEBUGNAME, INFONAME, WARNNAME, ERRORNAME, FATALNAME = []byte("[DEBUG]"), []byte("[INFO]"), []byte("[WARN]"), []byte("[ERROR]"), []byte("[FATAL]")
var TIME_DEVIATION time.Duration
Functions ¶
This section is empty.
Types ¶
type Logging ¶
type Logging struct {
// contains filtered or unexported fields
}
————————————————————————————————————————————————————————————————————————————
func SetGzipOn ¶
when set true, the specified backup file of both SetRollingFile and SetRollingFileLoop will be save as a compressed file
func SetRollingByTime ¶
like SetRollingDaily,but supporte hourly backup ,dayly backup and monthly backup mode : MODE_HOUR MODE_DAY MODE_MONTH
func SetRollingDaily ¶
yesterday's log data is backed up to a specified log file each day Parameters:
- fileDir :directory where log files are stored, If it is the current directory, you also can set it to ""
- fileName : log file name
func SetRollingFile ¶
func SetRollingFile(fileDir, fileName string, maxFileSize int64, unit _UNIT) (l *Logging, err error)
when the log file(fileDir+`\`+fileName) exceeds the specified size(maxFileSize), it will be backed up with a specified file name Parameters:
- fileDir :directory where log files are stored, If it is the current directory, you also can set it to ""
- fileName : log file name
- maxFileSize : maximum size of a log file
- unit : size unit : KB,MB,GB,TB
func SetRollingFileLoop ¶
func SetRollingFileLoop(fileDir, fileName string, maxFileSize int64, unit _UNIT, maxFileNum int) (l *Logging, err error)
like SetRollingFile,but only keep (maxFileNum) current files - maxFileNum : the number of files that are retained
func (*Logging) SetRollingByTime ¶
func (t *Logging) SetRollingByTime(fileDir, fileName string, mode _MODE_TIME) (l *Logging, err error)
指定按 小时,天,月 分割日志文件 fileDir 日志文件夹路径 fileName 日志文件名 mode 指定 小时,天,月
func (*Logging) SetRollingDaily ¶
按日期分割日志文件 fileDir 日志文件夹路径 fileName 日志文件名
func (*Logging) SetRollingFile ¶
func (t *Logging) SetRollingFile(fileDir, fileName string, maxFileSize int64, unit _UNIT) (l *Logging, err error)
按日志文件大小分割日志文件 fileDir 日志文件夹路径 fileName 日志文件名 maxFileSize 日志文件大小最大值 unit 日志文件大小单位