Documentation ¶
Overview ¶
Package log implements adapters between logging types of various used packages
Index ¶
- Variables
- func AlwaysFalseFilter(_ zapcore.Entry) bool
- func AlwaysTrueFilter(_ zapcore.Entry) bool
- func ColorLevel(l Level) string
- func NewGRPCLogger(logger *Logger) grpclog.LoggerV2
- func NewPionLogger(base *Logger, scope string) logging.LeveledLogger
- func NewPionLoggerFactory(base *Logger) logging.LoggerFactory
- func ResetWidths()
- func UpdateFilter(f *Filter)
- type Filter
- type FilterFunc
- func All(filterFuncs ...FilterFunc) FilterFunc
- func Any(filterFuncs ...FilterFunc) FilterFunc
- func ByLevels(pattern string) (FilterFunc, error)
- func ByNamespaces(input string) FilterFunc
- func ParseRule(rule string) (FilterFunc, error)
- func ParseRules(rules []string) (FilterFunc, error)
- func Reverse(filterFunc FilterFunc) FilterFunc
- type Level
- type Logger
- type PionLoggerFactory
Constants ¶
This section is empty.
Variables ¶
var ( ColorTime = tty.Color256(223) ColorContext = tty.Color256(249) ColorStacktrace = tty.Color256(249) ColorName = tty.Color256(145) ColorCaller = tty.Color256(15) ColorLevelUnknown = tty.Color256(1) ColorLevelDebugVerbose = tty.Color256(138) ColorLevels = map[Level]string{ DebugLevel: tty.Color256(138), InfoLevel: tty.Color256(12), WarnLevel: tty.Color256(208), ErrorLevel: tty.Color256(124), DPanicLevel: tty.Color256(196), PanicLevel: tty.Color256(196), FatalLevel: tty.Color256(196), } )
var ( ErrUnsupportedKeyword = errors.New("unsupported keyword") ErrBadSyntax = errors.New("bad syntax") )
var ( MaxLevel = FatalLevel MinLevel = VerboseLevel(10) TraceLevel = MinLevel )
Functions ¶
func AlwaysFalseFilter ¶
func AlwaysTrueFilter ¶
func ColorLevel ¶
func NewGRPCLogger ¶
func NewPionLogger ¶
func NewPionLogger(base *Logger, scope string) logging.LeveledLogger
func NewPionLoggerFactory ¶
func NewPionLoggerFactory(base *Logger) logging.LoggerFactory
func ResetWidths ¶
func ResetWidths()
func UpdateFilter ¶
func UpdateFilter(f *Filter)
Types ¶
type Filter ¶
type Filter struct { FilterFunc Rules []string // The list of rules used to construct the filter Level Level // The highest level which the filter lets pass-through }
func CurrentFilter ¶
func CurrentFilter() *Filter
func ParseFilter ¶
type FilterFunc ¶
FilterFunc is used to check whether to filter the given entry and filters out.
func ByLevels ¶
func ByLevels(pattern string) (FilterFunc, error)
ByLevels creates a FilterFunc based on a pattern.
Syntax
pattern: LEVELS LEVELS: LEVEL[,LEVELS] LEVEL: one of - SEVERITY for matching all levels with equal or higher severity - >SEVERITY for matching all levels with equal or higher severity - =SEVERITY for matching all levels with equal severity - <SEVERITY for matching all levels with lower severity
func ByNamespaces ¶
func ByNamespaces(input string) FilterFunc
ByNamespaces takes a list of patterns to filter out logs based on their namespaces. Patterns are checked using path.Match.
func ParseRule ¶
func ParseRule(rule string) (FilterFunc, error)
ParseRules takes a CLI-friendly set of rules to construct a filter. Syntax
rule: RULE RULE: one of: - LEVELS:NAMESPACES - LEVELS LEVELS: LEVEL[,LEVELS] LEVEL: see `Level Patterns` NAMESPACES: NAMESPACE[,NAMESPACES] NAMESPACE: one of: - namespace // Should be exactly this namespace - *mat*ch* // Should match - -NAMESPACE // Should not match
func ParseRules ¶
func ParseRules(rules []string) (FilterFunc, error)
ParseRules takes a CLI-friendly set of rules to construct a filter.
Syntax
rules: slice of RULE
func Reverse ¶
func Reverse(filterFunc FilterFunc) FilterFunc
Reverse checks is the passed filter returns false.
func (FilterFunc) Level ¶
func (f FilterFunc) Level() zapcore.Level
type PionLoggerFactory ¶
type PionLoggerFactory struct {
// contains filtered or unexported fields
}
PionLoggerFactory is a logger factory backended by zap logger.
func (*PionLoggerFactory) NewLogger ¶
func (f *PionLoggerFactory) NewLogger(scope string) logging.LeveledLogger
NewLogger creates new scoped logger.
func (*PionLoggerFactory) SyncAll ¶
func (f *PionLoggerFactory) SyncAll()
SyncAll calls Sync() method of all child loggers. It is recommended to call this before exiting the program to ensure never loosing buffered log.