log

package
v0.16.1-rc.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TRACE zapcore.Level = iota - 2
	DEBUG
	INFO
	WARN
	ERROR
)

Variables

View Source
var ErrUnknownLogLevel = fmt.Errorf(
	"unknown log level (known: %s, %s, %s, %s, %s)",
	TRACE, DEBUG, INFO, WARN, ERROR,
)

Functions

func HTTPLogSettings

func HTTPLogSettings(w http.ResponseWriter, r *http.Request, log *Level)

HTTPLogSettings is an HTTP handler that allows changing the log level of the logger. It can also be used to query what's the current log level.

func SanitizeString

func SanitizeString(s string) string

SanitizeString sanitises a string by removing characters that could compromise log integrity or be used for log injection. Also useful to avoid CodeQL CI errors like this: https://github.com/NethermindEth/juno/security/code-scanning/662

Types

type Level

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

func NewLevel

func NewLevel(level zapcore.Level) *Level

func (Level) GetAtomicLevel

func (l Level) GetAtomicLevel() zap.AtomicLevel

func (Level) Level

func (l Level) Level() zapcore.Level

func (*Level) MarshalText

func (l *Level) MarshalText() ([]byte, error)

func (Level) MarshalYAML

func (l Level) MarshalYAML() (any, error)

func (*Level) Set

func (l *Level) Set(s string) error

func (Level) String

func (l Level) String() string

func (*Level) Type

func (l *Level) Type() string

func (*Level) UnmarshalText

func (l *Level) UnmarshalText(text []byte) error

type Logger

type Logger interface {
	pebble.Logger
	StructuredLogger
}

type LoggerOption

type LoggerOption func(*loggerConfig)

func WithColour

func WithColour(colour bool) LoggerOption

func WithJSON

func WithJSON(json bool) LoggerOption

func WithWriter

func WithWriter(w io.Writer) LoggerOption

note(rdr): functionality wise so far this is only used for testing purposes

type StructuredLogger

type StructuredLogger interface {
	Debug(msg string, fields ...zap.Field)
	Info(msg string, fields ...zap.Field)
	Warn(msg string, fields ...zap.Field)
	Error(msg string, fields ...zap.Field)
	Trace(msg string, fields ...zap.Field)
}

type ZapLogger

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

func NewNopZapLogger

func NewNopZapLogger() *ZapLogger

func NewZapLogger

func NewZapLogger(logLevel *Level, opts ...LoggerOption) (*ZapLogger, error)

func NewZapLoggerWithConfig

func NewZapLoggerWithConfig(config *zap.Config) (*ZapLogger, error)

func NewZapLoggerWithCore

func NewZapLoggerWithCore(core zapcore.Core) *ZapLogger

func (*ZapLogger) Debug

func (l *ZapLogger) Debug(msg string, fields ...zap.Field)

func (*ZapLogger) Error

func (l *ZapLogger) Error(msg string, fields ...zap.Field)

func (*ZapLogger) Errorf

func (l *ZapLogger) Errorf(msg string, args ...any)

func (*ZapLogger) Fatalf

func (l *ZapLogger) Fatalf(msg string, args ...any)

func (*ZapLogger) Info

func (l *ZapLogger) Info(msg string, fields ...zap.Field)

func (*ZapLogger) Infof

func (l *ZapLogger) Infof(msg string, args ...any)

func (*ZapLogger) IsTraceEnabled

func (l *ZapLogger) IsTraceEnabled() bool

func (*ZapLogger) Name

func (l *ZapLogger) Name() string

Name returns the logger name. Logger is unamed by default

func (*ZapLogger) Named

func (l *ZapLogger) Named(name string) *ZapLogger

Named clones the logger and re-names it.

func (*ZapLogger) Trace

func (l *ZapLogger) Trace(msg string, fields ...zap.Field)

func (*ZapLogger) Warn

func (l *ZapLogger) Warn(msg string, fields ...zap.Field)

func (*ZapLogger) WithOptions

func (l *ZapLogger) WithOptions(opts ...zap.Option) *ZapLogger

Jump to

Keyboard shortcuts

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