blog

package
v11.0.16 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package blog is the brokerapi logger BrokerAPI was originally written to use the CloudFoundry Lager logger (https://github.com/cloudfoundry/lager), and it relied on some idiosyncrasies of that logger that are not found in the (subsequently written) Go standard library log/slog logger. This package is a wrapper around log/slog that adds back the idiosyncrasies of lager, minimizes boilerplate code, and keeps the behavior as similar as possible. It also implements the slog.Handler interface so that it can easily be converted into a slog.Logger. This is useful when calling public APIs (such as FailureResponse.ValidatedStatusCode) which take a slog.Logger as an input, and because they are public cannot take a Blog as an input.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindingID

func BindingID(bindingID string) slog.Attr

BindingID creates an attribute from an binding ID

func InstanceID

func InstanceID(instanceID string) slog.Attr

InstanceID creates an attribute from an instance ID

Types

type Blog

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

func New

func New(logger *slog.Logger) Blog

func (Blog) Enabled

func (b Blog) Enabled(context.Context, slog.Level) bool

Enabled is required implement the slog.Handler interface

func (Blog) Error

func (b Blog) Error(message string, err error, attr ...any)

Error logs an error. It takes an error type as a convenience, which is different to slog.Logger.Error()

func (Blog) Handle

func (b Blog) Handle(_ context.Context, record slog.Record) error

Handle is required implement the slog.Handler interface

func (Blog) Info

func (b Blog) Info(message string, attr ...any)

Info logs information. It behaves a lot file slog.Logger.Info()

func (Blog) Session

func (b Blog) Session(ctx context.Context, prefix string, attr ...any) Blog

Session emulates a Lager logger session. It returns a new logger that will always log the attributes, prefix, and data from the context.

func (Blog) With

func (b Blog) With(attr ...any) Blog

With returns a logger that always logs the specified attributes

func (Blog) WithAttrs

func (b Blog) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs is required implement the slog.Handler interface

func (Blog) WithGroup

func (b Blog) WithGroup(string) slog.Handler

WithGroup is required implement the slog.Handler interface

Jump to

Keyboard shortcuts

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