glog

package
v1.6.9 Latest Latest
Warning

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

Go to latest
Published: May 6, 2019 License: MIT Imports: 15 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_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
)

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

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

func Fatalf

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

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

func Fatalfln

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 added in v1.5.0

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 GetLevel

func GetLevel() int

GetLevel returns the default logging level value.

func GetPath

func GetPath() string

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

func GetWriter

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

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 added in v1.5.0

func PrintBacktrace(skip ...int)

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

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

func SetBacktrace(enabled bool)

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

func SetDebug

func SetDebug(debug bool)

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

func SetFile

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

func SetLevel(level int)

SetLevel sets the default logging level.

func SetPath

func SetPath(path string)

SetPath sets the directory path for file logging.

func SetStdPrint added in v1.5.0

func SetStdPrint(open bool)

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

func SetWriter

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

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 added in v1.5.0

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

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

func Cat

func Cat(category string) *Logger

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

func File

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

func Level(level int) *Logger

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

func New

func New() *Logger

New creates and returns a custom logger.

func Path

func Path(path string) *Logger

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

func StdPrint added in v1.5.0

func StdPrint(enabled bool) *Logger

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

func To

func To(writer io.Writer) *Logger

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

func (*Logger) Backtrace added in v1.5.0

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

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

func (l *Logger) Clone() *Logger

Clone returns a new logger, which is the clone the current 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{})

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

func (*Logger) Fatalf

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

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

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 added in v1.5.0

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) GetLevel

func (l *Logger) GetLevel() int

GetLevel returns the logging level value.

func (*Logger) GetPath

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

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

GetWriter returns the customized writer object, which implements the io.Writer interface. It returns a default writer if no customized writer set.

func (*Logger) Header

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

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

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

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) Path

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

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

func (*Logger) PrintBacktrace added in v1.5.0

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

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 added in v1.5.0

func (l *Logger) SetBacktrace(enabled bool)

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

func (*Logger) SetBacktraceSkip added in v1.5.0

func (l *Logger) SetBacktraceSkip(skip int)

SetBacktraceSkip sets the backtrace offset from the end point.

func (*Logger) SetDebug

func (l *Logger) SetDebug(debug bool)

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

func (*Logger) SetFile

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

func (l *Logger) SetLevel(level int)

SetLevel sets the logging level.

func (*Logger) SetPath

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

SetPath sets the directory path for file logging.

func (*Logger) SetStdPrint added in v1.5.0

func (l *Logger) SetStdPrint(enabled bool)

SetStdPrint sets whether output the logging contents to stdout, which is false in default.

func (*Logger) SetWriter

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) StdPrint

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

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

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

type Writer added in v1.6.3

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

func (*Writer) Write added in v1.6.3

func (w *Writer) Write(p []byte) (n int, err error)

Write implements the io.Writer interface. It just prints the content with header or level.

Jump to

Keyboard shortcuts

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