gf: github.com/gogf/gf/g/os/glog Index | Files

package glog

import "github.com/gogf/gf/g/os/glog"

Package glog implements powerful and easy-to-use levelled logging functionality.

日志模块, 直接文件/输出操作,没有异步逻辑,没有使用缓存或者通道

Index

Package Files

glog.go glog_logger.go glog_logger_chaining.go

Constants

const (
    LEVEL_ALL  = LEVEL_DEBU | LEVEL_INFO | LEVEL_NOTI | LEVEL_WARN | LEVEL_ERRO | LEVEL_CRIT
    LEVEL_DEV  = LEVEL_ALL
    LEVEL_PROD = LEVEL_WARN | LEVEL_ERRO | LEVEL_CRIT
    LEVEL_DEBU = 1 << iota
    LEVEL_INFO
    LEVEL_NOTI
    LEVEL_WARN
    LEVEL_ERRO
    LEVEL_CRIT
)

func Critical Uses

func Critical(v ...interface{})

func Criticalf Uses

func Criticalf(format string, v ...interface{})

func Criticalfln Uses

func Criticalfln(format string, v ...interface{})

func Debug Uses

func Debug(v ...interface{})

func Debugf Uses

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

func Debugfln Uses

func Debugfln(format string, v ...interface{})

func Error Uses

func Error(v ...interface{})

func Errorf Uses

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

func Errorfln Uses

func Errorfln(format string, v ...interface{})

func Fatal Uses

func Fatal(v ...interface{})

Fatal prints the logging content with [FATA] header and newline, then exit the current process.

func Fatalf Uses

func Fatalf(format string, v ...interface{})

Fatalf prints the logging content with [FATA] header and custom format, then exit the current process.

func Fatalfln Uses

func Fatalfln(format string, v ...interface{})

Fatalf prints the logging content with [FATA] header, custom format and newline, then exit the current process.

func GetBacktrace Uses

func GetBacktrace(skip ...int) string

GetBacktrace returns the caller backtrace content, the optional parameter <skip> specify the skipped backtraces offset from the end point.

获取文件调用回溯信息.

func GetLevel Uses

func GetLevel() int

GetLevel returns the default logging level value.

获取全局的日志记录等级.

func GetPath Uses

func GetPath() string

GetPath returns the logging directory path for file logging. It returns empty string if no directory path set.

获取日志目录绝对路径

func GetWriter Uses

func GetWriter() io.Writer

GetWriter returns the customed writer object, which implements the io.Writer interface. It returns nil if no customed writer set.

返回自定义的IO,默认为nil.

func Info Uses

func Info(v ...interface{})

func Infof Uses

func Infof(format string, v ...interface{})

func Infofln Uses

func Infofln(format string, v ...interface{})

func Notice Uses

func Notice(v ...interface{})

func Noticef Uses

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

func Noticefln Uses

func Noticefln(format string, v ...interface{})

func Panic Uses

func Panic(v ...interface{})

func Panicf Uses

func Panicf(format string, v ...interface{})

func Panicfln Uses

func Panicfln(format string, v ...interface{})

func Print Uses

func Print(v ...interface{})

func PrintBacktrace Uses

func PrintBacktrace(skip ...int)

PrintBacktrace prints the caller backtrace, the optional parameter <skip> specify the skipped backtraces offset from the end point.

打印文件调用回溯信息

func Printf Uses

func Printf(format string, v ...interface{})

func Printfln Uses

func Printfln(format string, v ...interface{})

func Println Uses

func Println(v ...interface{})

func SetBacktrace Uses

func SetBacktrace(enabled bool)

SetBacktrace enables/disables the backtrace feature in failure logging outputs.

是否关闭全局的backtrace信息

func SetDebug Uses

func SetDebug(debug bool)

SetDebug enables/disables the debug level for default logger. The debug level is enbaled in default.

设置是否允许输出DEBUG信息.

func SetFile Uses

func SetFile(pattern string)

SetFile sets the file name <pattern> for file logging. Datetime pattern can be used in <pattern>, eg: access-{Ymd}.log. The default file name pattern is: Y-m-d.log, eg: 2018-01-01.log

日志文件名称.

func SetLevel Uses

func SetLevel(level int)

SetLevel sets the default logging level.

设置全局的日志记录等级.

func SetPath Uses

func SetPath(path string)

SetPath sets the directory path for file logging.

日志日志目录绝对路径.

func SetStdPrint Uses

func SetStdPrint(open bool)

SetStdPrint sets whether ouptput the logging contents to stdout, which is false indefault.

设置写日志的同时开启or关闭控制台打印,默认是关闭的

func SetWriter Uses

func SetWriter(writer io.Writer)

SetWriter sets the customed logging <writer> for logging. The <writer> object should implements the io.Writer interface. Developer can use customed logging <writer> to redirect logging output to another service, eg: kafka, mysql, mongodb, etc.

可自定义IO接口,IO可以是文件输出、标准输出、网络输出.

func Warning Uses

func Warning(v ...interface{})

func Warningf Uses

func Warningf(format string, v ...interface{})

func Warningfln Uses

func Warningfln(format string, v ...interface{})

type Logger Uses

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

func Backtrace Uses

func Backtrace(enabled bool, skip ...int) *Logger

Backtrace is a chaining function, which sets backtrace options for the current logging content output .

设置文件调用回溯信息.

func Cat Uses

func Cat(category string) *Logger

Cat is a chaining function, which sets the category to <category> for current logging content output.

设置下一次输出的分类,支持多级分类设置.

func File Uses

func File(pattern string) *Logger

File is a chaining function, which sets file name <pattern> for the current logging content output.

设置日志输出文件名称格式

func Header(enabled bool) *Logger

Header is a chaining function, which enables/disables log header for the current logging content output.

是否打印每行日志头信息(默认开启)

func Level Uses

func Level(level int) *Logger

Level is a chaining function, which sets logging level for the current logging content output.

设置日志打印等级.

func New Uses

func New() *Logger

New creates a custom logger.

新建自定义的日志操作对象

func Path Uses

func Path(path string) *Logger

Path is a chaining function, which sets the directory path to <path> for current logging content output.

链式操作,设置下一次输出的日志路径。

func StdPrint Uses

func StdPrint(enabled bool) *Logger

StdPrint is a chaining function, which enables/disables stdout for the current logging content output.

是否允许在设置输出文件时同时也输出到终端

func To Uses

func To(writer io.Writer) *Logger

To is a chaining function, which redirects current logging content output to the sepecified <writer>.

链式操作,设置下一次写入日志内容的Writer

func (*Logger) Backtrace Uses

func (l *Logger) Backtrace(enabled bool, skip ...int) *Logger

Backtrace is a chaining function, which sets backtrace options for the current logging content output .

设置文件调用回溯信息

func (*Logger) Cat Uses

func (l *Logger) Cat(category string) *Logger

Cat is a chaining function, which sets the category to <category> for current logging content output.

链式操作,设置下一次输出的日志分类(可以按照文件目录层级设置),在当前logpath或者当前工作目录下创建category目录, 这是一个链式操作,可以设置多个分类,将会创建层级的日志分类目录。

func (*Logger) Clone Uses

func (l *Logger) Clone() *Logger

Clone returns a new logger, which is the clone the current logger.

Logger拷贝.

func (*Logger) Critical Uses

func (l *Logger) Critical(v ...interface{})

func (*Logger) Criticalf Uses

func (l *Logger) Criticalf(format string, v ...interface{})

func (*Logger) Criticalfln Uses

func (l *Logger) Criticalfln(format string, v ...interface{})

func (*Logger) Debug Uses

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

func (*Logger) Debugf Uses

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

func (*Logger) Debugfln Uses

func (l *Logger) Debugfln(format string, v ...interface{})

func (*Logger) Error Uses

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

func (*Logger) Errorf Uses

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

func (*Logger) Errorfln Uses

func (l *Logger) Errorfln(format string, v ...interface{})

func (*Logger) Fatal Uses

func (l *Logger) Fatal(v ...interface{})

Fatal prints the logging content with [FATA] header and newline, then exit the current process.

func (*Logger) Fatalf Uses

func (l *Logger) Fatalf(format string, v ...interface{})

Fatalf prints the logging content with [FATA] header and custom format, then exit the current process.

func (*Logger) Fatalfln Uses

func (l *Logger) Fatalfln(format string, v ...interface{})

Fatalf prints the logging content with [FATA] header, custom format and newline, then exit the current process.

func (*Logger) File Uses

func (l *Logger) File(file string) *Logger

File is a chaining function, which sets file name <pattern> for the current logging content output.

日志文件格式

func (*Logger) GetBacktrace Uses

func (l *Logger) GetBacktrace(skip ...int) string

GetBacktrace returns the caller backtrace content, the optional parameter <skip> specify the skipped backtraces offset from the end point.

获取文件调用回溯字符串,参数skip表示调用端往上多少级开始回溯

func (*Logger) GetLevel Uses

func (l *Logger) GetLevel() int

GetLevel returns the logging level value.

获取日志记录等级

func (*Logger) GetPath Uses

func (l *Logger) GetPath() string

GetPath returns the logging directory path for file logging. It returns empty string if no directory path set.

获取设置的日志目录路径

func (*Logger) GetWriter Uses

func (l *Logger) GetWriter() io.Writer

GetWriter returns the customed writer object, which implements the io.Writer interface. It returns nil if no customed writer set.

返回自定义的IO,默认为nil

func (*Logger) Header Uses

func (l *Logger) Header(enabled bool) *Logger

Header is a chaining function, which enables/disables log header for the current logging content output.

是否打印每行日志头信息(默认开启)

func (*Logger) Info Uses

func (l *Logger) Info(v ...interface{})

func (*Logger) Infof Uses

func (l *Logger) Infof(format string, v ...interface{})

func (*Logger) Infofln Uses

func (l *Logger) Infofln(format string, v ...interface{})

func (*Logger) Level Uses

func (l *Logger) Level(level int) *Logger

Level is a chaining function, which sets logging level for the current logging content output.

设置日志打印等级

func (*Logger) Notice Uses

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

func (*Logger) Noticef Uses

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

func (*Logger) Noticefln Uses

func (l *Logger) Noticefln(format string, v ...interface{})

func (*Logger) Panic Uses

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

func (*Logger) Panicf Uses

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

func (*Logger) Panicfln Uses

func (l *Logger) Panicfln(format string, v ...interface{})

func (*Logger) Path Uses

func (l *Logger) Path(path string) *Logger

Path is a chaining function, which sets the directory path to <path> for current logging content output.

链式操作,设置下一次输出的日志路径。

func (*Logger) Print Uses

func (l *Logger) Print(v ...interface{})

func (*Logger) PrintBacktrace Uses

func (l *Logger) PrintBacktrace(skip ...int)

PrintBacktrace prints the caller backtrace, the optional parameter <skip> specify the skipped backtraces offset from the end point.

直接打印回溯信息,参数skip表示调用端往上多少级开始回溯

func (*Logger) Printf Uses

func (l *Logger) Printf(format string, v ...interface{})

func (*Logger) Printfln Uses

func (l *Logger) Printfln(format string, v ...interface{})

func (*Logger) Println Uses

func (l *Logger) Println(v ...interface{})

func (*Logger) SetBacktrace Uses

func (l *Logger) SetBacktrace(enabled bool)

SetBacktrace enables/disables the backtrace feature in failure logging outputs.

func (*Logger) SetBacktraceSkip Uses

func (l *Logger) SetBacktraceSkip(skip int)

SetBacktraceSkip sets the backtrace offset from the end point.

func (*Logger) SetDebug Uses

func (l *Logger) SetDebug(debug bool)

SetDebug enables/disables the debug level for logger. The debug level is enbaled in default.

快捷方法,打开或关闭DEBU日志信息

func (*Logger) SetFile Uses

func (l *Logger) SetFile(pattern string)

SetFile sets the file name <pattern> for file logging. Datetime pattern can be used in <pattern>, eg: access-{Ymd}.log. The default file name pattern is: Y-m-d.log, eg: 2018-01-01.log

设置日志文件名称格式.

func (*Logger) SetLevel Uses

func (l *Logger) SetLevel(level int)

SetLevel sets the logging level.

设置日志记录等级

func (*Logger) SetPath Uses

func (l *Logger) SetPath(path string) error

SetPath sets the directory path for file logging.

设置日志文件的存储目录路径.

func (*Logger) SetStdPrint Uses

func (l *Logger) SetStdPrint(enabled bool)

SetStdPrint sets whether ouptput the logging contents to stdout, which is false indefault.

设置写日志时开启or关闭控制台打印,默认是关闭的

func (*Logger) SetWriter Uses

func (l *Logger) SetWriter(writer io.Writer)

SetWriter sets the customed logging <writer> for logging. The <writer> object should implements the io.Writer interface. Developer can use customed logging <writer> to redirect logging output to another service, eg: kafka, mysql, mongodb, etc.

可自定义IO接口,IO可以是文件输出、标准输出、网络输出

func (*Logger) StdPrint Uses

func (l *Logger) StdPrint(enabled bool) *Logger

StdPrint is a chaining function, which enables/disables stdout for the current logging content output.

是否允许在设置输出文件时同时也输出到终端

func (*Logger) To Uses

func (l *Logger) To(writer io.Writer) *Logger

To is a chaining function, which redirects current logging content output to the specified <writer>.

链式操作,设置下一次写入日志内容的Writer

func (*Logger) Warning Uses

func (l *Logger) Warning(v ...interface{})

func (*Logger) Warningf Uses

func (l *Logger) Warningf(format string, v ...interface{})

func (*Logger) Warningfln Uses

func (l *Logger) Warningfln(format string, v ...interface{})

Package glog imports 15 packages (graph) and is imported by 20 packages. Updated 2019-03-23. Refresh now. Tools for package owners.