Documentation ¶
Index ¶
- func DecisionIDFromContext(ctx context.Context) (string, bool)
- func NewContext(parent context.Context, val *RequestContext) context.Context
- func WithDecisionID(parent context.Context, id string) context.Context
- type HTTPRequestContext
- type Level
- type Logger
- type NoOpLogger
- func (*NoOpLogger) Debug(string, ...interface{})
- func (*NoOpLogger) Error(string, ...interface{})
- func (l *NoOpLogger) GetLevel() Level
- func (*NoOpLogger) Info(string, ...interface{})
- func (l *NoOpLogger) SetLevel(level Level)
- func (*NoOpLogger) Warn(string, ...interface{})
- func (l *NoOpLogger) WithFields(fields map[string]interface{}) Logger
- type RequestContext
- type StandardLogger
- func (l *StandardLogger) Debug(fmt string, a ...interface{})
- func (l *StandardLogger) Error(fmt string, a ...interface{})
- func (l *StandardLogger) GetLevel() Level
- func (l *StandardLogger) Info(fmt string, a ...interface{})
- func (l *StandardLogger) SetFormatter(formatter logrus.Formatter)
- func (l *StandardLogger) SetLevel(level Level)
- func (l *StandardLogger) SetOutput(w io.Writer)
- func (l *StandardLogger) Warn(fmt string, a ...interface{})
- func (l *StandardLogger) WithFields(fields map[string]interface{}) Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecisionIDFromContext ¶ added in v0.50.0
func NewContext ¶ added in v0.46.0
func NewContext(parent context.Context, val *RequestContext) context.Context
NewContext returns a copy of parent with an associated RequestContext.
Types ¶
type HTTPRequestContext ¶ added in v0.65.0
type Logger ¶
type Logger interface { Debug(fmt string, a ...interface{}) Info(fmt string, a ...interface{}) Error(fmt string, a ...interface{}) Warn(fmt string, a ...interface{}) WithFields(map[string]interface{}) Logger GetLevel() Level SetLevel(Level) }
Logger provides interface for OPA logger implementations
type NoOpLogger ¶
type NoOpLogger struct {
// contains filtered or unexported fields
}
NoOpLogger logging implementation that does nothing
func (*NoOpLogger) WithFields ¶
func (l *NoOpLogger) WithFields(fields map[string]interface{}) Logger
WithFields provides additional fields to include in log output. Implemented here primarily to be able to switch between implementations without loss of data.
type RequestContext ¶ added in v0.46.0
type RequestContext struct { ClientAddr string ReqID uint64 ReqMethod string ReqPath string HTTPRequestContext HTTPRequestContext }
RequestContext represents the request context used to store data related to the request that could be used on logs.
func FromContext ¶ added in v0.46.0
func FromContext(ctx context.Context) (*RequestContext, bool)
FromContext returns the RequestContext associated with ctx, if any.
func (RequestContext) Fields ¶ added in v0.46.0
func (rctx RequestContext) Fields() logrus.Fields
Fields adapts the RequestContext fields to logrus.Fields.
type StandardLogger ¶
type StandardLogger struct {
// contains filtered or unexported fields
}
StandardLogger is the default OPA logger implementation.
func Get ¶ added in v0.31.0
func Get() *StandardLogger
Get returns the standard logger used throughout OPA.
Deprecated. Do not rely on the global logger.
func (*StandardLogger) Debug ¶
func (l *StandardLogger) Debug(fmt string, a ...interface{})
Debug logs at debug level
func (*StandardLogger) Error ¶
func (l *StandardLogger) Error(fmt string, a ...interface{})
Error logs at error level
func (*StandardLogger) GetLevel ¶
func (l *StandardLogger) GetLevel() Level
GetLevel returns the standard logger level.
func (*StandardLogger) Info ¶
func (l *StandardLogger) Info(fmt string, a ...interface{})
Info logs at info level
func (*StandardLogger) SetFormatter ¶
func (l *StandardLogger) SetFormatter(formatter logrus.Formatter)
SetFormatter sets the underlying logrus formatter.
func (*StandardLogger) SetLevel ¶
func (l *StandardLogger) SetLevel(level Level)
SetLevel sets the standard logger level.
func (*StandardLogger) SetOutput ¶ added in v0.34.0
func (l *StandardLogger) SetOutput(w io.Writer)
SetOutput sets the underlying logrus output.
func (*StandardLogger) Warn ¶
func (l *StandardLogger) Warn(fmt string, a ...interface{})
Warn logs at warn level
func (*StandardLogger) WithFields ¶
func (l *StandardLogger) WithFields(fields map[string]interface{}) Logger
WithFields provides additional fields to include in log output