Documentation
¶
Overview ¶
Code generated by gommon from log/gommon.yml DO NOT EDIT.
Code generated by gommon from log/logger_generated.go.tmpl DO NOT EDIT.
Package log is not usable yet, see legacy/log
Index ¶
- Constants
- Variables
- func NewTestHandler() *testHandler
- func PreOrderDFS(root *Logger, visited map[*Logger]bool, cb func(l *Logger))
- func SetHandlerRecursive(root *Logger, handler Handler)
- func SetLevelRecursive(root *Logger, level Level)
- func ToStringTree(root *Logger) *structure.StringTreeNode
- type Field
- type Fields
- type Handler
- type HandlerFunc
- type Identity
- type Level
- type LoggableStruct
- type Logger
- func NewApplicationLogger() *Logger
- func NewFunctionLogger(packageLogger *Logger) *Logger
- func NewLibraryLogger() *Logger
- func NewMethodLogger(structLogger *Logger) *Logger
- func NewPackageLogger() *Logger
- func NewPackageLoggerWithSkip(skip int) *Logger
- func NewStructLogger(packageLogger *Logger, loggable LoggableStruct) *Logger
- func (l *Logger) AddChild(child *Logger)
- func (l *Logger) Debug(args ...interface{})
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(args ...interface{})
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Fatal(args ...interface{})
- func (l *Logger) Fatalf(format string, args ...interface{})
- func (l *Logger) Identity() *Identity
- func (l *Logger) Info(args ...interface{})
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) IsDebugEnabled() bool
- func (l *Logger) IsErrorEnabled() bool
- func (l *Logger) IsInfoEnabled() bool
- func (l *Logger) IsTraceEnabled() bool
- func (l *Logger) IsWarnEnabled() bool
- func (l *Logger) Level() Level
- func (l *Logger) Panic(args ...interface{})
- func (l *Logger) Panicf(format string, args ...interface{})
- func (l *Logger) PrintTree()
- func (l *Logger) PrintTreeTo(w io.Writer)
- func (l *Logger) SetHandler(h Handler)
- func (l *Logger) SetLevel(level Level)
- func (l *Logger) Trace(args ...interface{})
- func (l *Logger) Tracef(format string, args ...interface{})
- func (l *Logger) Warn(args ...interface{})
- func (l *Logger) Warnf(format string, args ...interface{})
- type LoggerType
Constants ¶
const MagicPackageLoggerFunctionName = "init"
const MagicStructLoggerFunctionName = "LoggerIdentity"
Variables ¶
var UnknownIdentity = Identity{Package: "unk", Type: UnknownLogger}
Functions ¶
func NewTestHandler ¶
func NewTestHandler() *testHandler
func PreOrderDFS ¶
TODO: test it ....
func SetHandlerRecursive ¶
func SetLevelRecursive ¶
func ToStringTree ¶
func ToStringTree(root *Logger) *structure.StringTreeNode
Types ¶
type HandlerFunc ¶
HandlerFunc is an adapter to allow use of ordinary functions as log entry handlers
func (HandlerFunc) HandleLog ¶
func (f HandlerFunc) HandleLog(level Level, msg string)
TODO: why the receiver is value instead of pointer https://github.com/dyweb/gommon/issues/30
type Identity ¶
type Identity struct {
Package string
Function string
Struct string
File string
Line int
Type LoggerType
}
Identity is based where the logger is initialized, it is NOT exactly where the log happens. It is used for applying filter rules and print logger hierarchy. TODO: example
func NewIdentityFromCaller ¶
TODO: document all the black magic here ... https://github.com/dyweb/gommon/issues/32
func (*Identity) Diff ¶
TODO: this is used for print tree like structure ... it's hard to maintain exact parent and child logger due to cycle import
func (*Identity) SourceLocation ¶
type Level ¶
type Level uint8
Level is log level
const ( // FatalLevel log error and call `os.Exit(1)` // TODO: allow user hook exit? FatalLevel Level = iota // PanicLevel log error and call `panic` PanicLevel // ErrorLevel log error ErrorLevel // WarnLevel log warning WarnLevel // InfoLevel log info InfoLevel // DebugLevel log debug message, user should enable DebugLevel logging when report bug DebugLevel // TraceLevel is very verbose, user should enable it only on packages they are currently investing instead of globally TraceLevel )
type LoggableStruct ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func NewApplicationLogger ¶
func NewApplicationLogger() *Logger
func NewFunctionLogger ¶
func NewLibraryLogger ¶
func NewLibraryLogger() *Logger
func NewMethodLogger ¶
func NewPackageLogger ¶
func NewPackageLogger() *Logger
func NewStructLogger ¶
func NewStructLogger(packageLogger *Logger, loggable LoggableStruct) *Logger
func (*Logger) IsDebugEnabled ¶
func (*Logger) IsErrorEnabled ¶
func (*Logger) IsInfoEnabled ¶
func (*Logger) IsTraceEnabled ¶
func (*Logger) IsWarnEnabled ¶
func (*Logger) PrintTreeTo ¶
func (*Logger) SetHandler ¶
type LoggerType ¶
type LoggerType uint8
const ( UnknownLogger LoggerType = iota ApplicationLogger LibraryLogger PackageLogger FunctionLogger StructLogger MethodLogger )
func (LoggerType) String ¶
func (tpe LoggerType) String() string
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
_examples
|
|
|
simple
command
|
|
|
uselib
command
|
|
|
handlers
|
|
|
stdio
Package stdio can be used with stderr/stdout/file and all the writer that implemented WriteSyncer interface its code is almost identical with default handler, but we duplicate the code to avoid cycle import
|
Package stdio can be used with stderr/stdout/file and all the writer that implemented WriteSyncer interface its code is almost identical with default handler, but we duplicate the code to avoid cycle import |