ctxlog

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package ctxlog extends ctxlog with events

Index

Constants

View Source
const (
	// ReasonPredicates is used for controller predicate related logging
	ReasonPredicates = "Predicates"
	// ReasonMapping is used for controller EnqueueRequestsFromMapFunc related logging
	ReasonMapping = "Mapping"
)

Variables

This section is empty.

Functions

func Debug

func Debug(ctx context.Context, v ...interface{})

Debug uses the stored zap logger

func Debugf

func Debugf(ctx context.Context, format string, v ...interface{})

Debugf uses the stored zap logger

func Error

func Error(ctx context.Context, v ...interface{})

Error uses the stored zap logger

func Errorf

func Errorf(ctx context.Context, format string, v ...interface{})

Errorf uses the stored zap logger

func ExtractLogger

func ExtractLogger(ctx context.Context) *zap.SugaredLogger

ExtractLogger returns the logger from the context

func ExtractRecorder added in v0.2.0

func ExtractRecorder(ctx context.Context) record.EventRecorder

ExtractRecorder returns the event recorder from the context

func Info

func Info(ctx context.Context, v ...interface{})

Info uses the stored zap logger

func Infof

func Infof(ctx context.Context, format string, v ...interface{})

Infof uses the stored zap logger

func NewContextWithRecorder added in v0.2.0

func NewContextWithRecorder(ctx context.Context, name string, recorder record.EventRecorder) context.Context

NewContextWithRecorder returns a new child context with the named recorder and log inside

func NewParentContext added in v0.2.0

func NewParentContext(log *zap.SugaredLogger) context.Context

NewParentContext returns a new context with a logger

func WarningEvent added in v0.2.0

func WarningEvent(ctx context.Context, object runtime.Object, reason, msg string)

WarningEvent will create a warning event, without logging

Types

type Event added in v0.3.1

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

func WithEvent added in v0.2.0

func WithEvent(object runtime.Object, reason string) Event

WithEvent returns a struct to provide event enhanced logging methods

func (Event) DebugJSON added in v0.3.1

func (ev Event) DebugJSON(ctx context.Context, objectInfo interface{})

DebugJSON logs a message and adds an info event in json format

func (Event) Debugf added in v0.3.1

func (ev Event) Debugf(ctx context.Context, format string, v ...interface{})

Debugf logs and adds an info event

func (Event) Error added in v0.3.1

func (ev Event) Error(ctx context.Context, parts ...interface{}) error

Error uses the stored zap logger and recorder

func (Event) Errorf added in v0.3.1

func (ev Event) Errorf(ctx context.Context, format string, v ...interface{}) error

Errorf uses the stored zap logger and the recorder to log an error, it returns an error like fmt.Errorf 'object' is the object this event is about. Event will make a reference-- or you may also pass a reference to the object directly. 'reason' is the reason this event is generated. 'reason' should be short and unique; it should be in UpperCamelCase format (starting with a capital letter). "reason" will be used to automate handling of events, so imagine people writing switch statements to handle them. You want to make that easy.

func (Event) Infof added in v0.3.1

func (ev Event) Infof(ctx context.Context, format string, v ...interface{})

Infof logs and adds an info event

type MappingEvent added in v0.3.1

type MappingEvent struct {
	Event
}

func NewMappingEvent added in v0.3.1

func NewMappingEvent(object runtime.Object) MappingEvent

NewMappingEvent returns a log event with the 'mapping' reason

func (MappingEvent) Debug added in v0.3.1

func (ev MappingEvent) Debug(ctx context.Context, reconciliation reconcile.Request, crd string, objName string, objType string)

Debug is used for logging in EnqueueRequestsFromMapFunc

type PredicateEvent added in v0.3.1

type PredicateEvent struct {
	Event
}

func NewPredicateEvent added in v0.3.1

func NewPredicateEvent(object runtime.Object) PredicateEvent

NewPredicateEvent returns a log event with the 'predicate' reason

func (PredicateEvent) Debug added in v0.3.1

func (ev PredicateEvent) Debug(ctx context.Context, meta metav1.Object, resource string, msg string)

Debug is used for predicate logging in the controllers

type ReconcileEventsFromSource added in v0.3.0

type ReconcileEventsFromSource struct {
	ReconciliationObjectName string `json:"reconciliationObjectName"`
	ReconciliationObjectKind string `json:"reconciliationObjectKind"`
	PredicateObjectName      string `json:"predicateObjectName"`
	PredicateObjectKind      string `json:"predicateObjectKind"`
	Namespace                string `json:"namespace"`
	Message                  string `json:"message"`
	Type                     string `json:"type"`
}

ReconcileEventsFromSource for defining useful logs when defining a mapping between a watched object and a reconcile one

func GenReconcilePredicatesObject added in v0.3.0

func GenReconcilePredicatesObject(ns string, t string, msg string, rKind string, pKind string) ReconcileEventsFromSource

GenReconcilePredicatesObject ...

Jump to

Keyboard shortcuts

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