tbr_logging

package
v0.0.0-...-f26ea48 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: AGPL-3.0 Imports: 2 Imported by: 9

Documentation

Overview

bronger/tools – Go tools of Torsten Bronger

Copyright (C) 2023 Torsten Bronger, bronger@physik.rwth-aachen.de

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(w io.Writer, level slog.Level)

Init sets up logging with slog.

Types

type Logger

type Logger interface {
	Warn(msg string, args ...any)
	Info(msg string, args ...any)
	Debug(msg string, args ...any)
	With(args ...any) *slog.Logger
}

Logger may be used as the type for library function arguments. This way, you can inject a logger into the library as an explicit dependency. It is designed so that slog.Default() could be used straight away as a value. For loggers with differing function signatures, you probably have to write a wrapper in the main package. Note that errors should not be logged by libraries but reported to the caller.

Jump to

Keyboard shortcuts

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