flog

package module
v0.0.0-...-308c7e9 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package flog provides slog helpers shared by various FerretDB projects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConsoleHandler

func NewConsoleHandler(out io.Writer, opts *NewConsoleHandlerOpts) slog.Handler

NewConsoleHandler creates a new console handler.

If out is a valid tty, the consoleHandler will send colorized messages. If NO_COLOR environment variable is set colorized messages are disabled.

func TestingLogger

func TestingLogger(tl TestingLog, level slog.Leveler) *slog.Logger

TestingLogger returns a slog test logger for the given level (which might be dynamic).

func TestingOutput

func TestingOutput(tl TestingLog) io.Writer

TestingOutput returns a new io.Writer for testing.TB.

It should not be used once https://github.com/golang/go/issues/59928 is resolved (probably in Go 1.25).

Types

type NewConsoleHandlerOpts

type NewConsoleHandlerOpts struct {
	Level        slog.Leveler
	RemoveTime   bool
	RemoveLevel  bool
	RemoveSource bool
}

NewConsoleHandlerOpts represents NewConsoleHandler options.

type TestingLog

type TestingLog interface {
	Helper()
	Log(args ...any)
}

TestingLog is a subset of testing.TB. It is used to avoid importing the testing package.

Jump to

Keyboard shortcuts

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