Documentation
¶
Index ¶
- func Close()
- func CopyStandardLogTo(name string)
- func DisableTerminal()
- func EnableFile()
- func Error(args ...interface{})
- func ErrorDepth(depth int, args ...interface{})
- func Errorf(format string, args ...interface{})
- func Errorln(args ...interface{})
- func Exit(args ...interface{})
- func ExitDepth(depth int, args ...interface{})
- func Exitf(format string, args ...interface{})
- func Exitln(args ...interface{})
- func Fatal(args ...interface{})
- func FatalDepth(depth int, args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Fatalln(args ...interface{})
- func Info(args ...interface{})
- func InfoDepth(depth int, args ...interface{})
- func Infof(format string, args ...interface{})
- func Infoln(args ...interface{})
- func SetContentType(tp MsgType)
- func SetDefault(l *LoggingT)
- func SetLevel(level int)
- func SetTrace(backtrace string)
- func SetVModule(v string)
- func Truncate(path string, capacity int64, f *os.File) error
- func Warning(args ...interface{})
- func WarningDepth(depth int, args ...interface{})
- func Warningf(format string, args ...interface{})
- func Warningln(args ...interface{})
- type DailyRotateRule
- type Level
- type LogConf
- type LoggingT
- func (l *LoggingT) Close()
- func (l *LoggingT) DisableTerminal()
- func (l *LoggingT) EnableFile()
- func (l *LoggingT) Error(args ...interface{})
- func (l *LoggingT) ErrorDepth(depth int, args ...interface{})
- func (l *LoggingT) Errorf(format string, args ...interface{})
- func (l *LoggingT) Errorln(args ...interface{})
- func (l *LoggingT) Exit(args ...interface{})
- func (l *LoggingT) ExitDepth(depth int, args ...interface{})
- func (l *LoggingT) Exitf(format string, args ...interface{})
- func (l *LoggingT) Exitln(args ...interface{})
- func (l *LoggingT) Fatal(args ...interface{})
- func (l *LoggingT) FatalDepth(depth int, args ...interface{})
- func (l *LoggingT) Fatalf(format string, args ...interface{})
- func (l *LoggingT) Fatalln(args ...interface{})
- func (l *LoggingT) Info(args ...interface{})
- func (l *LoggingT) InfoDepth(depth int, args ...interface{})
- func (l *LoggingT) Infof(format string, args ...interface{})
- func (l *LoggingT) Infoln(args ...interface{})
- func (l *LoggingT) SetContentType(tp MsgType) error
- func (l *LoggingT) SetLevel(level int)
- func (l *LoggingT) SetTrace(backtrace string) error
- func (l *LoggingT) SetUp(c *LogConf)
- func (l *LoggingT) SetVModule(value string) error
- func (l *LoggingT) V(level Level) Verbose
- func (l *LoggingT) Warning(args ...interface{})
- func (l *LoggingT) WarningDepth(depth int, args ...interface{})
- func (l *LoggingT) Warningf(format string, args ...interface{})
- func (l *LoggingT) Warningln(args ...interface{})
- type MsgType
- type RotateLogger
- type RotateRule
- type Verbose
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyStandardLogTo ¶
func CopyStandardLogTo(name string)
CopyStandardLogTo arranges for messages written to the Go "log" package's default logs to also appear in the Google logs for the named and lower severities. Subsequent changes to the standard log's default output location or format may break this behavior.
Valid names are "INFO", "WARNING", "ERROR", and "FATAL". If the name is not recognized, CopyStandardLogTo panics.
func Error ¶
func Error(args ...interface{})
Error logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func ErrorDepth ¶
func ErrorDepth(depth int, args ...interface{})
ErrorDepth acts as Error but uses depth to determine which call frame to log. ErrorDepth(0, "msg") is the same as Error("msg").
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func Errorln ¶
func Errorln(args ...interface{})
Errorln logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
func Exit ¶
func Exit(args ...interface{})
Exit logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func ExitDepth ¶
func ExitDepth(depth int, args ...interface{})
ExitDepth acts as Exit but uses depth to determine which call frame to log. ExitDepth(0, "msg") is the same as Exit("msg").
func Exitf ¶
func Exitf(format string, args ...interface{})
Exitf logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func Exitln ¶
func Exitln(args ...interface{})
Exitln logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1).
func Fatal ¶
func Fatal(args ...interface{})
Fatal logs to the FATAL, ERROR, WARNING, and INFO logs, including a stack trace of all running goroutines, then calls os.Exit(255). Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func FatalDepth ¶
func FatalDepth(depth int, args ...interface{})
FatalDepth acts as Fatal but uses depth to determine which call frame to log. FatalDepth(0, "msg") is the same as Fatal("msg").
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf logs to the FATAL, ERROR, WARNING, and INFO logs, including a stack trace of all running goroutines, then calls os.Exit(255). Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func Fatalln ¶
func Fatalln(args ...interface{})
Fatalln logs to the FATAL, ERROR, WARNING, and INFO logs, including a stack trace of all running goroutines, then calls os.Exit(255). Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
func Info ¶
func Info(args ...interface{})
Info logs to the INFO log. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func InfoDepth ¶
func InfoDepth(depth int, args ...interface{})
InfoDepth acts as Info but uses depth to determine which call frame to log. InfoDepth(0, "msg") is the same as Info("msg").
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func Infoln ¶
func Infoln(args ...interface{})
Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
func SetDefault ¶ added in v1.1.0
func SetDefault(l *LoggingT)
func SetVModule ¶
func SetVModule(v string)
func Warning ¶
func Warning(args ...interface{})
Warning logs to the WARNING and INFO logs. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func WarningDepth ¶
func WarningDepth(depth int, args ...interface{})
WarningDepth acts as Warning but uses depth to determine which call frame to log. WarningDepth(0, "msg") is the same as Warning("msg").
Types ¶
type DailyRotateRule ¶
type DailyRotateRule struct {
// contains filtered or unexported fields
}
A DailyRotateRule is a rule to daily rotate the log files.
func (*DailyRotateRule) BackupFileName ¶
func (r *DailyRotateRule) BackupFileName() string
BackupFileName returns the backup filename on rotating.
func (*DailyRotateRule) MarkRotated ¶
func (r *DailyRotateRule) MarkRotated()
MarkRotated marks the rotated time of r to be the current time.
func (*DailyRotateRule) MaxSize ¶
func (r *DailyRotateRule) MaxSize() int64
func (*DailyRotateRule) OutdatedFiles ¶
func (r *DailyRotateRule) OutdatedFiles() []string
OutdatedFiles returns the files that exceeded the keeping days.
func (*DailyRotateRule) SetFileName ¶
func (r *DailyRotateRule) SetFileName(fname string) bool
func (*DailyRotateRule) ShallRotate ¶
func (r *DailyRotateRule) ShallRotate(nbytes int) bool
ShallRotate checks if the file should be rotated.
type LogConf ¶
type LogConf struct { ServiceName string `json:"name,optional"` //此日志服务名,默认为程序名。 V int `json:"level,default=0"` //此日志的全局等级,超过此等级的日志不显示和保存 Vmodule string `json:"vmodule,optional"` //遵守全局V等级设置下,再按照文件设置等级,格式为 文件名=等级,此文件名不带后缀,比如 main=3 Backtrace string `json:"backtrace,optional"` //追踪日志,格式为文件名:行号,比如main.go:234,此文件名带后缀 WriteConsole bool `json:"console,default=true"` //是否打印屏幕 //下面的为文件相关配置 WriteFile bool `json:"writefile,default=false"` //是否保存文件 Path string `json:"path,default=logs"` //保存文件的目录 Compress bool `json:"compress,optional"` //日志文件备份是否zip压缩 KeepDays int `json:"keepdays,optional"` //日志文件保存天数,0表示永久保存 MaxSize int `json:"maxsize,default=8388608"` //单个日志文件的最大容量,超过此值就需要切换新文件,避免单个文件过大。默认8M。 FlushTm int `json:"flushtm,default=5"` //多少秒刷新一次文件 ContentType int64 `json:"contenttype,default=0"` //输出日志的类型,0:默认格式 1:自定义格式 2:json格式 TimeFormat string `json:",optional"` //ContentType!=0时,自定义时间戳格式 类似"2006-01-02 15:04:05.000000" }
type LoggingT ¶
type LoggingT struct {
// contains filtered or unexported fields
}
LoggingT collects all the global state of the logging setup.
func (*LoggingT) DisableTerminal ¶
func (l *LoggingT) DisableTerminal()
func (*LoggingT) EnableFile ¶
func (l *LoggingT) EnableFile()
func (*LoggingT) Error ¶
func (l *LoggingT) Error(args ...interface{})
Error logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func (*LoggingT) ErrorDepth ¶
ErrorDepth acts as Error but uses depth to determine which call frame to log. ErrorDepth(0, "msg") is the same as Error("msg").
func (*LoggingT) Errorf ¶
Errorf logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func (*LoggingT) Errorln ¶
func (l *LoggingT) Errorln(args ...interface{})
Errorln logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
func (*LoggingT) Exit ¶
func (l *LoggingT) Exit(args ...interface{})
Exit logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func (*LoggingT) ExitDepth ¶
ExitDepth acts as Exit but uses depth to determine which call frame to log. ExitDepth(0, "msg") is the same as Exit("msg").
func (*LoggingT) Exitf ¶
Exitf logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func (*LoggingT) Exitln ¶
func (l *LoggingT) Exitln(args ...interface{})
Exitln logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1).
func (*LoggingT) Fatal ¶
func (l *LoggingT) Fatal(args ...interface{})
Fatal logs to the FATAL, ERROR, WARNING, and INFO logs, including a stack trace of all running goroutines, then calls os.Exit(255). Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func (*LoggingT) FatalDepth ¶
FatalDepth acts as Fatal but uses depth to determine which call frame to log. FatalDepth(0, "msg") is the same as Fatal("msg").
func (*LoggingT) Fatalf ¶
Fatalf logs to the FATAL, ERROR, WARNING, and INFO logs, including a stack trace of all running goroutines, then calls os.Exit(255). Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func (*LoggingT) Fatalln ¶
func (l *LoggingT) Fatalln(args ...interface{})
Fatalln logs to the FATAL, ERROR, WARNING, and INFO logs, including a stack trace of all running goroutines, then calls os.Exit(255). Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
func (*LoggingT) Info ¶
func (l *LoggingT) Info(args ...interface{})
Info logs to the INFO log. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func (*LoggingT) InfoDepth ¶
InfoDepth acts as Info but uses depth to determine which call frame to log. InfoDepth(0, "msg") is the same as Info("msg").
func (*LoggingT) Infof ¶
Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func (*LoggingT) Infoln ¶
func (l *LoggingT) Infoln(args ...interface{})
Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
func (*LoggingT) SetContentType ¶
func (*LoggingT) SetTrace ¶
Syntax: -log_backtrace_at=gopherflakes.go:234 Note that unlike vmodule the file extension is included here.
func (*LoggingT) SetVModule ¶
Syntax: -vmodule=recordio=2,file=1,gfs*=3
func (*LoggingT) Warning ¶
func (l *LoggingT) Warning(args ...interface{})
Warning logs to the WARNING and INFO logs. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func (*LoggingT) WarningDepth ¶
WarningDepth acts as Warning but uses depth to determine which call frame to log. WarningDepth(0, "msg") is the same as Warning("msg").
type RotateLogger ¶
type RotateLogger struct {
// contains filtered or unexported fields
}
A RotateLogger is a Logger that can rotate log files with given rules.
func NewLogger ¶
func NewLogger(sev severity, logT *LoggingT, tag string, rule RotateRule, compress bool) (*RotateLogger, error)
NewLogger returns a RotateLogger with given filename and rule, etc.
func (*RotateLogger) Sync ¶
func (l *RotateLogger) Sync() error
func (*RotateLogger) WriteHeader ¶
func (l *RotateLogger) WriteHeader()
type RotateRule ¶
type RotateRule interface { BackupFileName() string MarkRotated() OutdatedFiles() []string ShallRotate(int) bool SetFileName(string) bool MaxSize() int64 }
A RotateRule interface is used to define the log rotating rules.
func DefaultRotateRule ¶
func DefaultRotateRule(filename, delimiter string, opt *logOptions) RotateRule
DefaultRotateRule is a default log rotating rule, currently DailyRotateRule.
type Verbose ¶
type Verbose struct {
// contains filtered or unexported fields
}
Verbose is a boolean type that implements Infof (like Printf) etc. See the documentation of V for more information.
func V ¶
V reports whether verbosity at the call site is at least the requested level. The returned value is a boolean of type Verbose, which implements Info, Infoln and Infof. These methods will write to the Info log if called. Thus, one may write either
if glog.V(2) { glog.Info("log this") }
or
glog.V(2).Info("log this")
The second form is shorter but the first is cheaper if logging is off because it does not evaluate its arguments.
Whether an individual call to V generates a log record depends on the setting of the -v and --vmodule flags; both are off by default. If the level in the call to V is at least the value of -v, or of -vmodule for the source file containing the call, the V call will log.
func (Verbose) Info ¶
func (v Verbose) Info(args ...interface{})
Info is equivalent to the global Info function, guarded by the value of v. See the documentation of V for usage.