glog

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

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

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

Index

Constants

View Source
const (
	LEVEL_ALL  = LEVEL_DEBU | LEVEL_INFO | LEVEL_NOTI | LEVEL_WARN | LEVEL_ERRO | LEVEL_CRIT
	LEVEL_DEBU = 1 << iota
	LEVEL_INFO
	LEVEL_NOTI
	LEVEL_WARN
	LEVEL_ERRO
	LEVEL_CRIT
)

Variables

This section is empty.

Functions

func Critical

func Critical(v ...interface{})

func Criticalf

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

func Criticalfln

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

func Debug

func Debug(v ...interface{})

func Debugf

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

func Debugfln

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

func Error

func Error(v ...interface{})

func Errorf

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

func Errorfln

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

func Fatal

func Fatal(v ...interface{})

func Fatalf

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

func Fatalfln

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

func GetBacktrace

func GetBacktrace(skip ...int) string

获取文件调用回溯信息

func GetLevel

func GetLevel() int

获取全局的日志记录等级

func GetPath

func GetPath() string

获取日志目录绝对路径

func GetWriter added in v1.1.994

func GetWriter() io.Writer

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

func Info

func Info(v ...interface{})

func Infof

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

func Infofln

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

func Notice

func Notice(v ...interface{})

func Noticef

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

func Noticefln

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

func Panic

func Panic(v ...interface{})

func Panicf

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

func Panicfln

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

func Print

func Print(v ...interface{})

func PrintBacktrace

func PrintBacktrace(skip ...int)

打印文件调用回溯信息

func Printf

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

func Printfln

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

func Println

func Println(v ...interface{})

func SetBacktrace added in v1.1.994

func SetBacktrace(enabled bool)

是否关闭全局的backtrace信息

func SetDebug

func SetDebug(debug bool)

设置是否允许输出DEBUG信息

func SetFile

func SetFile(file string)

日志文件名称

func SetLevel

func SetLevel(level int)

设置全局的日志记录等级

func SetPath

func SetPath(path string)

日志日志目录绝对路径

func SetStdPrint

func SetStdPrint(open bool)

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

func SetWriter added in v1.1.994

func SetWriter(writer io.Writer)

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

func Warning

func Warning(v ...interface{})

func Warningf

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

func Warningfln

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

Types

type Logger

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

func Backtrace

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

设置文件调用回溯信息

func Cat

func Cat(category string) *Logger

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

func File

func File(file string) *Logger

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

func Header(enabled bool) *Logger

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

func Level

func Level(level int) *Logger

设置日志打印等级

func New

func New() *Logger

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

func StdPrint

func StdPrint(enabled bool) *Logger

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

func To added in v1.1.994

func To(writer io.Writer) *Logger

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

func (*Logger) Backtrace

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

设置文件调用回溯信息

func (*Logger) Cat

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

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

func (*Logger) Clone

func (l *Logger) Clone() *Logger

Logger深拷贝

func (*Logger) Critical

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

func (*Logger) Criticalf

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

func (*Logger) Criticalfln

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

func (*Logger) Debug

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

func (*Logger) Debugf

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

func (*Logger) Debugfln

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

func (*Logger) Error

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

func (*Logger) Errorf

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

func (*Logger) Errorfln

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

func (*Logger) Fatal

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

func (*Logger) Fatalf

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

func (*Logger) Fatalfln

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

func (*Logger) File

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

日志文件格式

func (*Logger) GetBacktrace

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

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

func (*Logger) GetLevel

func (l *Logger) GetLevel() int

获取日志记录等级

func (*Logger) GetPath

func (l *Logger) GetPath() string

获取设置的日志目录路径

func (*Logger) GetWriter

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

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

func (*Logger) Header

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

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

func (*Logger) Info

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

func (*Logger) Infof

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

func (*Logger) Infofln

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

func (*Logger) Level

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

设置日志打印等级

func (*Logger) Notice

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

func (*Logger) Noticef

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

func (*Logger) Noticefln

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

func (*Logger) Panic

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

func (*Logger) Panicf

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

func (*Logger) Panicfln

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

func (*Logger) Print

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

func (*Logger) PrintBacktrace

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

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

func (*Logger) Printf

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

func (*Logger) Printfln

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

func (*Logger) Println

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

func (*Logger) SetBacktrace

func (l *Logger) SetBacktrace(enabled bool)

func (*Logger) SetBacktraceSkip

func (l *Logger) SetBacktraceSkip(skip int)

设置BacktraceSkip

func (*Logger) SetDebug

func (l *Logger) SetDebug(debug bool)

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

func (*Logger) SetFile

func (l *Logger) SetFile(file string)

日志文件名称

func (*Logger) SetLevel

func (l *Logger) SetLevel(level int)

设置日志记录等级

func (*Logger) SetPath

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

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

func (*Logger) SetStdPrint

func (l *Logger) SetStdPrint(enabled bool)

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

func (*Logger) SetWriter

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

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

func (*Logger) StdPrint

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

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

func (*Logger) To added in v1.1.994

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

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

func (*Logger) Warning

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

func (*Logger) Warningf

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

func (*Logger) Warningfln

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

Jump to

Keyboard shortcuts

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