log

package
v0.0.0-...-68f58f5 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToContext

func ToContext(ctx context.Context, logger Logger) context.Context

ToContext adds a logger to the context that can be retrieved later. The logger will be used for operations performed with this context. If no logger is provided in the context, a no-op logger will be used.

Parameters:

  • ctx: The context to add the logger to
  • logger: The logger to store in the context

Returns:

  • context.Context: A new context with the logger stored

Types

type Logger

type Logger interface {
	Debug(msg string, keysAndValues ...any)
	Info(msg string, keysAndValues ...any)
	Error(msg string, keysAndValues ...any)
	Warn(msg string, keysAndValues ...any)
}

Logger is a minimal logging interface for nanogit clients.

func FromContext

func FromContext(ctx context.Context) Logger

FromContext retrieves the logger from the context. If no logger is stored in the context, nil will be returned.

Parameters:

  • ctx: The context to retrieve the logger from

Returns:

  • Logger: The logger stored in the context, or nil if none is found

type NoopLogger

type NoopLogger struct{}

noopLogger implements Logger but does nothing.

func (*NoopLogger) Debug

func (n *NoopLogger) Debug(msg string, keysAndValues ...any)

func (*NoopLogger) Error

func (n *NoopLogger) Error(msg string, keysAndValues ...any)

func (*NoopLogger) Info

func (n *NoopLogger) Info(msg string, keysAndValues ...any)

func (*NoopLogger) Warn

func (n *NoopLogger) Warn(msg string, keysAndValues ...any)

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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