log

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: Apache-2.0 Imports: 17 Imported by: 123

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Logger is a shared go-kit logger.
	// TODO: Change all components to take a non-global logger via their constructors.
	// Prefer accepting a non-global logger as an argument.
	Logger  = log.NewNopLogger()
	SLogger = promslog.NewNopLogger()
)

Functions

func CheckFatal

func CheckFatal(location string, err error)

CheckFatal prints an error and exits with error code 1 if err is non-nil

func ExtractSampledTraceID added in v1.17.0

func ExtractSampledTraceID(ctx context.Context) (string, bool)

ExtractSampledTraceID gets traceID and whether the trace is samples or not.

func GoKitLogToSlog added in v1.19.0

func GoKitLogToSlog(logger log.Logger) *slog.Logger

GoKitLogToSlog convert go-kit/log to slog usage: logutil.GoKitLogToSlog(gokitLogger)

func HeadersFromContext added in v1.18.0

func HeadersFromContext(ctx context.Context, l log.Logger) log.Logger

HeadersFromContext enables the logging of specified HTTP Headers that have been added to a context

func InitLogger

func InitLogger(cfg *server.Config)

InitLogger initialises the global gokit logger (util_log.Logger) and overrides the default logger for the server.

func NewPrometheusLogger

func NewPrometheusLogger(l logging.Level, format logging.Format) (log.Logger, error)

NewPrometheusLogger creates a new instance of PrometheusLogger which exposes Prometheus counters for various log levels.

func WarnExperimentalUse

func WarnExperimentalUse(feature string)

WarnExperimentalUse logs a warning and increments the experimental features metric.

func WithContext

func WithContext(ctx context.Context, l log.Logger) log.Logger

WithContext returns a Logger that has information about the current user in its details.

e.g.

log := util.WithContext(ctx)
log.Errorf("Could not chunk chunks: %v", err)

func WithExecutionID added in v1.18.0

func WithExecutionID(executionID string, l log.Logger) log.Logger

WithExecutionID returns a Logger that has information about the execution id in its details.

func WithSourceIPs

func WithSourceIPs(sourceIPs string, l log.Logger) log.Logger

WithSourceIPs returns a Logger that has information about the source IPs in its details.

func WithTraceID

func WithTraceID(traceID string, l log.Logger) log.Logger

WithTraceID returns a Logger that has information about the traceID in its details.

func WithUserID

func WithUserID(userID string, l log.Logger) log.Logger

WithUserID returns a Logger that has information about the current user in its details.

Types

type PrometheusLogger

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

PrometheusLogger exposes Prometheus counters for each of go-kit's log levels.

func (*PrometheusLogger) Log

func (pl *PrometheusLogger) Log(kv ...any) error

Log increments the appropriate Prometheus counter depending on the log level.

Jump to

Keyboard shortcuts

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