log

package
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupContext

func SetupContext(ctx context.Context, defaultWriter io.Writer) context.Context

SetupContext creates supplies a context.Context with new Logger instance It handles setting up logging level and log output

func WithCommandContext

func WithCommandContext(ctx context.Context, command string) context.Context

WithCommandContext returns a context withe a logger and supplied with given 'command' field

Types

type Handler

type Handler struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

Handler is a custom handler designed to work with or without colored output

func NewHandler

func NewHandler(w io.Writer, withColors bool) *Handler

NewHandler creates a new Handler instance with given parameters

func (*Handler) HandleLog

func (h *Handler) HandleLog(e *log.Entry) error

HandleLog works the same way as text.Handler from apex/log, but additionally disables coloring output when writing to a text file

type Logger

type Logger log.Interface

Logger is a type wrapper around log.Interface used to simplify imports in the project

func FromContext

func FromContext(ctx context.Context) Logger

FromContext wraps log.FromContext function to simplify imports in the project

func WithCommand

func WithCommand(ctx context.Context, command string) Logger

WithCommand returns a Logger supplied with given 'command' field

Jump to

Keyboard shortcuts

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