logging

package
v1.10.4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: Apache-2.0 Imports: 10 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// RecordLogFileName represents the default file name of the record log.
	RecordLogFileName = "sentinel-record.log"
	GlobalCallerDepth = 4
)

Variables

View Source
var (
	DefaultDirName = filepath.Join("logs", "csp")
)
View Source
var (
	FrequentErrorOnce = &sync.Once{}
)

Functions

func AssembleMsg

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

func Debug

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

func DebugEnabled

func DebugEnabled() bool

func Error

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

func ErrorEnabled

func ErrorEnabled() bool

func Info

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

func InfoEnabled

func InfoEnabled() bool

func ResetGlobalLogger

func ResetGlobalLogger(log Logger) error

ResetGlobalLogger sets the Sentinel global logger Note: this function is not thread-safe.

func ResetGlobalLoggerLevel

func ResetGlobalLoggerLevel(l Level)

ResetGlobalLoggerLevel sets the Sentinel log level Note: this function is not thread-safe.

func Warn

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

func WarnEnabled

func WarnEnabled() bool

Types

type DefaultLogger

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

sentinel general logger

func (*DefaultLogger) Debug

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

func (*DefaultLogger) DebugEnabled

func (l *DefaultLogger) DebugEnabled() bool

func (*DefaultLogger) Error

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

func (*DefaultLogger) ErrorEnabled

func (l *DefaultLogger) ErrorEnabled() bool

func (*DefaultLogger) Info

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

func (*DefaultLogger) InfoEnabled

func (l *DefaultLogger) InfoEnabled() bool

func (*DefaultLogger) Warn

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

func (*DefaultLogger) WarnEnabled

func (l *DefaultLogger) WarnEnabled() bool

type Level

type Level uint8

Level represents the level of logging.

const (
	DebugLevel Level = iota
	InfoLevel
	WarnLevel
	ErrorLevel
)

func GetGlobalLoggerLevel

func GetGlobalLoggerLevel() Level

GetGlobalLoggerLevel gets the Sentinel log level

type Logger

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

	// 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{})
	InfoEnabled() bool

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

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

func GetGlobalLogger

func GetGlobalLogger() Logger

GetGlobalLogger gets the Sentinel global logger

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