logging

package
v1.0.0-M1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2020 License: Apache-2.0 Imports: 9 Imported by: 90

Documentation

Index

Constants

View Source
const (
	// RecordLogFileName represents the default file name of the record log.
	RecordLogFileName = "sentinel-record.log"
	DefaultDirName    = "logs" + string(os.PathSeparator) + "csp" + string(os.PathSeparator)
	GlobalCallerDepth = 4
)

Variables

View Source
var (
	FrequentErrorOnce = &sync.Once{}
)

Functions

func AssembleMsg added in v1.0.0

func AssembleMsg(depth int, logLevel, msg string, err error, keysAndValues ...interface{}) string

func Debug

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

func Error

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

func Info

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

func ResetGlobalLogger added in v0.6.0

func ResetGlobalLogger(log Logger) error

Note: Not thread-safe

func SetGlobalLoggerLevel

func SetGlobalLoggerLevel(l Level)

func Warn

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

Types

type DefaultLogger added in v0.6.0

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

sentinel general logger

func (*DefaultLogger) Debug added in v0.6.0

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

func (*DefaultLogger) Error added in v0.6.0

func (l *DefaultLogger) Error(err error, msg string, keysAndValues ...interface{})

func (*DefaultLogger) Info added in v0.6.0

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

func (*DefaultLogger) Warn added in v0.6.0

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

type Level

type Level uint8

Level represents the level of logging.

const (
	DebugLevel Level = iota
	InfoLevel
	WarnLevel
	ErrorLevel
)

func GetGlobalLoggerLevel

func GetGlobalLoggerLevel() Level

type Logger

type Logger interface {
	Debug(msg string, keysAndValues ...interface{})

	// Info logs a non-error message with the given key/value pairs as context.
	//
	// The msg argument should be used to add some constant description to
	// the log line.  The key/value pairs can then be used to add additional
	// variable information.  The key/value pairs should alternate string
	// keys and arbitrary values.
	Info(msg string, keysAndValues ...interface{})

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

	Error(err error, msg string, keysAndValues ...interface{})
}

func NewConsoleLogger

func NewConsoleLogger() Logger

func NewSimpleFileLogger

func NewSimpleFileLogger(filepath string) (Logger, error)

outputFile is the full path(absolute path)

Jump to

Keyboard shortcuts

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