log

package
v0.0.0-...-24f16ac Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package log is a replacement for the standard log package based on slog. This should not be used unless writing debug statements. Most logging happens at the service level packages. Choose tracing over logging for production debugging.

Index

Constants

This section is empty.

Variables

View Source
var LogLevel = new(slog.LevelVar) // Info by default

LogLevel is the log level for the program. This is used to set the log level for the program. This is automatically set for the default logger unless .Set() is used to switch out that logger. If the new logger is created from the adapter package, it uses this LogLevel. If not, you must pass this to your logger manually.

Functions

func Default

func Default() *slog.Logger

Default returns the default logger. This logger should only be used outside main() and the gRPC service level if there is code running in a goroutine outside the request handling that needs to log messages or you need to pass the logger to a function outside of medbay. Anything other use of this logger (or any logger) is verboten.

func Fatal

func Fatal(v ...any)

Fatal is equivalent to Print followed by a call to os.Exit(1). If called in production, it will panic instead of exiting.

func Fatalf

func Fatalf(format string, v ...any)

Fatalf is equivalent to Printf followed by a call to os.Exit(1). If called in production, it will panic instead of exiting.

func Fatalln

func Fatalln(v ...any)

Fatalln is equivalent to Println followed by a call to os.Exit(1). If called in production, it will panic instead of exiting.

func Flags

func Flags() int

Flags returns the output flags for the standard logger. The flag bits are [Ldate], [Ltime], and so on.

func Panic

func Panic(v ...any)

Panic is equivalent to Print followed by a call to panic().

func Panicf

func Panicf(format string, v ...any)

Panicf is equivalent to Printf followed by a call to panic().

func Panicln

func Panicln(v ...any)

Panicln is equivalent to Println followed by a call to panic().

func Prefix

func Prefix() string

Prefix returns the output prefix for the standard logger.

func Print

func Print(v ...any)

Print calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Print.

func Printf

func Printf(format string, v ...any)

Printf calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Printf.

func Println

func Println(v ...any)

Println calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Println.

func Set

func Set(l *slog.Logger)

Set sets the logger returned by Default(). This must be done in main() before any logging is done to avoid a concurrency issue.

func SetFlags

func SetFlags(flag int)

SetFlags sets the output flags for the standard logger. The flag bits are [Ldate], [Ltime], and so on.

Types

This section is empty.

Directories

Path Synopsis
Package adapters provides adapters for converting logging instances to the *slog.Logger type.
Package adapters provides adapters for converting logging instances to the *slog.Logger type.
utils
debugstrip command
Package debugstrip provides a utility to reformat JSON log lines into a more human-readable format.
Package debugstrip provides a utility to reformat JSON log lines into a more human-readable format.

Jump to

Keyboard shortcuts

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