gf: github.com/johng-cn/gf/g/os/glog Index | Files

package glog

import "github.com/johng-cn/gf/g/os/glog"

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

Index

Package Files

glog.go glog_api.go glog_chaining.go glog_logger.go glog_logger_api.go glog_logger_chaining.go glog_logger_writer.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
)
const (
    F_FILE_LONG  = 1 << iota // Print full file name and line number: /a/b/c/d.go:23.
    F_FILE_SHORT             // Print final file name element and line number: d.go:23. overrides F_FILE_LONG.
    F_TIME_DATE              // Print the date in the local time zone: 2009-01-23.
    F_TIME_TIME              // Print the time in the local time zone: 01:23:23.
    F_TIME_MILLI             // Print the time with milliseconds in the local time zone: 01:23:23.675.
    F_TIME_STD   = F_TIME_DATE | F_TIME_MILLI
)

func Critical Uses

func Critical(v ...interface{})

Critical prints the logging content with [CRIT] header and newline. It also prints caller backtrace info if backtrace feature is enabled.

func Criticalf Uses

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

Criticalf prints the logging content with [CRIT] header and custom format. It also prints caller backtrace info if backtrace feature is enabled.

func Criticalfln Uses

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

Criticalfln prints the logging content with [CRIT] header, newline and custom format. It also prints caller backtrace info if backtrace feature is enabled.

func Debug Uses

func Debug(v ...interface{})

Debug prints the logging content with [DEBU] header and newline.

func Debugf Uses

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

Debugf prints the logging content with [DEBU] header and custom format.

func Debugfln Uses

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

Debugfln prints the logging content with [DEBU] header, newline and custom format.

func Error Uses

func Error(v ...interface{})

Error prints the logging content with [ERRO] header and newline. It also prints caller backtrace info if backtrace feature is enabled.

func Errorf Uses

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

Errorf prints the logging content with [ERRO] header and custom format. It also prints caller backtrace info if backtrace feature is enabled.

func Errorfln Uses

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

Errorfln prints the logging content with [ERRO] header, newline and custom format. It also prints caller backtrace info if backtrace feature is enabled.

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 backtrace offset from the end point.

func GetFlags Uses

func GetFlags() int

GetFlags returns the flags of logger.

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 customized writer object, which implements the io.Writer interface. It returns nil if no customized writer set.

func Info Uses

func Info(v ...interface{})

Info prints the logging content with [INFO] header and newline.

func Infof Uses

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

Infof prints the logging content with [INFO] header and custom format.

func Infofln Uses

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

Infofln prints the logging content with [INFO] header, newline and custom format.

func Notice Uses

func Notice(v ...interface{})

Notice prints the logging content with [NOTI] header and newline. It also prints caller backtrace info if backtrace feature is enabled.

func Noticef Uses

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

Noticef prints the logging content with [NOTI] header and custom format. It also prints caller backtrace info if backtrace feature is enabled.

func Noticefln Uses

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

Noticefln prints the logging content with [NOTI] header, newline and custom format. It also prints caller backtrace info if backtrace feature is enabled.

func Panic Uses

func Panic(v ...interface{})

Panic prints the logging content with [PANI] header and newline, then panics.

func Panicf Uses

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

Panicf prints the logging content with [PANI] header and custom format, then panics.

func Panicfln Uses

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

Panicfln prints the logging content with [PANI] header, newline and custom format, then panics.

func Print Uses

func Print(v ...interface{})

Print prints <v> with newline using fmt.Sprintln. The param <v> can be multiple variables.

func PrintBacktrace Uses

func PrintBacktrace(skip ...int)

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

func Printf Uses

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

Printf prints <v> with format <format> using fmt.Sprintf. The param <v> can be multiple variables.

func Printfln Uses

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

Printf prints <v> with newline and format <format> using fmt.Sprintf. The param <v> can be multiple variables.

func Println Uses

func Println(v ...interface{})

See Print.

func SetBacktrace Uses

func SetBacktrace(enabled bool)

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

func SetDebug Uses

func SetDebug(debug bool)

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

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 SetFlags Uses

func SetFlags(flags int)

SetFlags sets extra flags for logging output features.

func SetHeaderPrint Uses

func SetHeaderPrint(enabled bool)

SetHeaderPrint sets whether output header of the logging contents, which is true in default.

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 SetPrefix Uses

func SetPrefix(prefix string)

SetPrefix sets prefix string for every logging content. Prefix is part of header, which means if header output is shut, no prefix will be output.

func SetStdoutPrint Uses

func SetStdoutPrint(enabled bool)

SetStdoutPrint sets whether ouptput the logging contents to stdout, which is false in default.

func SetWriter Uses

func SetWriter(writer io.Writer)

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

func Warning Uses

func Warning(v ...interface{})

Warning prints the logging content with [WARN] header and newline. It also prints caller backtrace info if backtrace feature is enabled.

func Warningf Uses

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

Warningf prints the logging content with [WARN] header and custom format. It also prints caller backtrace info if backtrace feature is enabled.

func Warningfln Uses

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

Warningfln prints the logging content with [WARN] header, newline and custom format. It also prints caller backtrace info if backtrace feature is enabled.

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. It's enabled in default.

func Level Uses

func Level(level int) *Logger

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

func Line Uses

func Line(long ...bool) *Logger

Line is a chaining function, which enables/disables printing its caller file along with its line number. The param <long> specified whether print the long absolute file path, eg: /a/b/c/d.go:23.

func New Uses

func New() *Logger

New creates and returns 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 Skip Uses

func Skip(skip int) *Logger

Skip is a chaining function, which sets backtrace skip for the current logging content output. It also affects the caller file path checks when line number printing enabled.

func Stdout Uses

func Stdout(enabled ...bool) *Logger

StdPrint is a chaining function, which enables/disables stdout for the current logging content output. It's enabled in default.

func To Uses

func To(writer io.Writer) *Logger

To is a chaining function, which redirects current logging content output to the sepecified <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. Param <category> can be hierarchical, eg: module/user.

func (*Logger) Clone Uses

func (l *Logger) Clone() *Logger

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

func (*Logger) Critical Uses

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

Critical prints the logging content with [CRIT] header and newline. It also prints caller backtrace info if backtrace feature is enabled.

func (*Logger) Criticalf Uses

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

Criticalf prints the logging content with [CRIT] header and custom format. It also prints caller backtrace info if backtrace feature is enabled.

func (*Logger) Criticalfln Uses

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

Criticalfln prints the logging content with [CRIT] header, newline and custom format. It also prints caller backtrace info if backtrace feature is enabled.

func (*Logger) Debug Uses

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

Debug prints the logging content with [DEBU] header and newline.

func (*Logger) Debugf Uses

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

Debugf prints the logging content with [DEBU] header and custom format.

func (*Logger) Debugfln Uses

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

Debugfln prints the logging content with [DEBU] header, newline and custom format.

func (*Logger) Error Uses

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

Error prints the logging content with [ERRO] header and newline. It also prints caller backtrace info if backtrace feature is enabled.

func (*Logger) Errorf Uses

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

Errorf prints the logging content with [ERRO] header and custom format. It also prints caller backtrace info if backtrace feature is enabled.

func (*Logger) Errorfln Uses

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

Errorfln prints the logging content with [ERRO] header, newline and custom format. It also prints caller backtrace info if backtrace feature is enabled.

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{})

Fatalfln 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 backtrace offset from the end point.

func (*Logger) GetFlags Uses

func (l *Logger) GetFlags() int

GetFlags returns the flags of logger.

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 customized writer object, which implements the io.Writer interface. It returns nil if no writer previously set.

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. It's enabled in default.

func (*Logger) Info Uses

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

Info prints the logging content with [INFO] header and newline.

func (*Logger) Infof Uses

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

Infof prints the logging content with [INFO] header and custom format.

func (*Logger) Infofln Uses

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

Infofln prints the logging content with [INFO] header, newline and custom format.

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) Line Uses

func (l *Logger) Line(long ...bool) *Logger

Line is a chaining function, which enables/disables printing its caller file path along with its line number. The param <long> specified whether print the long absolute file path, eg: /a/b/c/d.go:23, or else short one: d.go:23.

func (*Logger) Notice Uses

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

Notice prints the logging content with [NOTI] header and newline. It also prints caller backtrace info if backtrace feature is enabled.

func (*Logger) Noticef Uses

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

Noticef prints the logging content with [NOTI] header and custom format. It also prints caller backtrace info if backtrace feature is enabled.

func (*Logger) Noticefln Uses

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

Noticefln prints the logging content with [NOTI] header, newline and custom format. It also prints caller backtrace info if backtrace feature is enabled.

func (*Logger) Panic Uses

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

Panic prints the logging content with [PANI] header and newline, then panics.

func (*Logger) Panicf Uses

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

Panicf prints the logging content with [PANI] header and custom format, then panics.

func (*Logger) Panicfln Uses

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

Panicfln prints the logging content with [PANI] header, newline and custom format, then panics.

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{})

Print prints <v> with newline using fmt.Sprintln. The param <v> can be multiple variables.

func (*Logger) PrintBacktrace Uses

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

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

func (*Logger) Printf Uses

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

Printf prints <v> with format <format> using fmt.Sprintf. The param <v> can be multiple variables.

func (*Logger) Printfln Uses

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

Printfln prints <v> with newline and format <format> using fmt.Sprintf. The param <v> can be multiple variables.

func (*Logger) Println Uses

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

See Print.

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 enabled in default.

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) SetFlags Uses

func (l *Logger) SetFlags(flags int)

SetFlags sets extra flags for logging output features.

func (*Logger) SetHeaderPrint Uses

func (l *Logger) SetHeaderPrint(enabled bool)

SetHeaderPrint sets whether output header of the logging contents, which is true in default.

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) SetPrefix Uses

func (l *Logger) SetPrefix(prefix string)

SetPrefix sets prefix string for every logging content. Prefix is part of header, which means if header output is shut, no prefix will be output.

func (*Logger) SetStdoutPrint Uses

func (l *Logger) SetStdoutPrint(enabled bool)

SetStdoutPrint sets whether output the logging contents to stdout, which is true in default.

func (*Logger) SetWriter Uses

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

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

func (*Logger) Skip Uses

func (l *Logger) Skip(skip int) *Logger

Skip is a chaining function, which sets backtrace skip for the current logging content output. It also affects the caller file path checks when line number printing enabled.

func (*Logger) StdPrint Uses

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

See Stdout. Deprecated.

func (*Logger) Stdout Uses

func (l *Logger) Stdout(enabled ...bool) *Logger

Stdout is a chaining function, which enables/disables stdout for the current logging content output. It's enabled in default.

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>.

func (*Logger) Warning Uses

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

Warning prints the logging content with [WARN] header and newline. It also prints caller backtrace info if backtrace feature is enabled.

func (*Logger) Warningf Uses

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

Warningf prints the logging content with [WARN] header and custom format. It also prints caller backtrace info if backtrace feature is enabled.

func (*Logger) Warningfln Uses

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

Warningfln prints the logging content with [WARN] header, newline and custom format. It also prints caller backtrace info if backtrace feature is enabled.

func (*Logger) Write Uses

func (l *Logger) Write(p []byte) (n int, err error)

Write implements the io.Writer interface. It just prints the content using Print.

Package glog imports 13 packages (graph). Updated 2019-05-24. Refresh now. Tools for package owners.