logger

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultLevel         = InfoLevel
	DefaultFlushInterval = time.Duration(3) * time.Second
)
View Source
const (
	TRACEE_LOGGER_LVL       = "TRACEE_LOGGER_LVL"
	TRACEE_LOGGER_ENCODER   = "TRACEE_LOGGER_ENCODER"
	TRACEE_LOGGER_AGGREGATE = "TRACEE_LOGGER_AGGREGATE"
)

Variables

View Source
var (
	NewDevelopmentConfig = zap.NewDevelopmentConfig
	NewProductionConfig  = zap.NewProductionConfig
)
View Source
var (
	NewConsoleEncoder = zapcore.NewConsoleEncoder
	NewJSONEncoder    = zapcore.NewJSONEncoder
)
View Source
var (
	NewDevelopmentEncoderConfig = zap.NewDevelopmentEncoderConfig
	NewProductionEncoderConfig  = zap.NewProductionEncoderConfig
)

Functions

func Debug

func Debug(msg string, keysAndValues ...interface{})

func Error

func Error(msg string, keysAndValues ...interface{})

func Fatal

func Fatal(msg string, keysAndValues ...interface{})

func HasDebugLevel added in v0.11.0

func HasDebugLevel() bool

HasDebugLevel returns true if logger has debug level

func Info

func Info(msg string, keysAndValues ...interface{})

func Init

func Init(cfg *LoggerConfig)

Init sets the package-level base logger using given config It's not thread safe so if required use it always at the beggining

func IsSetFromEnv

func IsSetFromEnv() bool

func Log added in v0.11.0

func Log(lvl Level, innerAggregation bool, msg string, keysAndValues ...interface{})

Log is a generic helper that allows logging by choosing the desired level and if the aggregation should be done. It does NOT override those options. For the case where innerAggregation is set to true, it will only aggregate if pkg logger's aggregation config is also set to true.

func SetBase

func SetBase(l *Logger)

SetBase sets package-level base logger It's not thread safe so if required use it always at the beggining

func Warn

func Warn(msg string, keysAndValues ...interface{})

Types

type Config

type Config = zap.Config

type Encoder

type Encoder = zapcore.Encoder

type EncoderConfig

type EncoderConfig = zapcore.EncoderConfig

type Level

type Level = zapcore.Level
const (
	DebugLevel  Level = zap.DebugLevel
	InfoLevel   Level = zap.InfoLevel
	WarnLevel   Level = zap.WarnLevel
	ErrorLevel  Level = zap.ErrorLevel
	DPanicLevel Level = zap.DPanicLevel
	PanicLevel  Level = zap.PanicLevel
	FatalLevel  Level = zap.FatalLevel
)

func GetLevel added in v0.11.0

func GetLevel() Level

GetLevel returns the logger level

type LogCounter

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

func (*LogCounter) Dump

func (lc *LogCounter) Dump() map[LogOrigin]uint32

func (*LogCounter) Flush added in v0.11.1

func (lc *LogCounter) Flush() map[LogOrigin]uint32

func (*LogCounter) Lookup

func (lc *LogCounter) Lookup(key LogOrigin) (count uint32, found bool)

type LogOrigin

type LogOrigin struct {
	File  string
	Line  int
	Level Level
	Msg   string
}

type Logger

type Logger struct {
	LogCount *LogCounter // updated only on debug level and cfg.Aggregate == true
	// contains filtered or unexported fields
}

Logger struct

func Base

func Base() *Logger

Base returns the package-level base logger

func NewLogger

func NewLogger(cfg *LoggerConfig) *Logger

NewLogger function

func (*Logger) Debug

func (l *Logger) Debug(msg string, keysAndValues ...interface{})

func (*Logger) Error

func (l *Logger) Error(msg string, keysAndValues ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, keysAndValues ...interface{})

func (*Logger) Info

func (l *Logger) Info(msg string, keysAndValues ...interface{})

func (*Logger) Sync

func (l *Logger) Sync() error

Sync

func (*Logger) Warn

func (l *Logger) Warn(msg string, keysAndValues ...interface{})

type LoggerConfig

type LoggerConfig struct {
	Writer        io.Writer
	Level         Level
	Encoder       Encoder
	Aggregate     bool
	FlushInterval time.Duration
}

func NewDefaultLoggerConfig

func NewDefaultLoggerConfig() *LoggerConfig

Jump to

Keyboard shortcuts

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