log

package
v0.5.18 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: Apache-2.0 Imports: 5 Imported by: 4

Documentation

Overview

Package log provides a lightweight thread-safe logging facility using structured logging (slog) with JSON output format. It offers a singleton logger instance with configurable log levels through environment variables and convenience methods for fatal error logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fatal

func Fatal(msg string)

Fatal logs a message at Fatal level and then calls os.Exit(1).

func FatalF

func FatalF(format string, args ...any)

FatalF logs a formatted message at Fatal level and then calls os.Exit(1). It follows the printf formatting rules.

func FatalLn

func FatalLn(args ...any)

FatalLn logs a message at Fatal level with a line feed and then calls os.Exit(1).

func Level

func Level() slog.Level

Level returns the logging level for the SPIKE components.

It reads from the SPIKE_SYSTEM_LOG_LEVEL environment variable and converts it to the corresponding slog.Level value. Valid values (case-insensitive) are:

  • "DEBUG": returns slog.LevelDebug
  • "INFO": returns slog.LevelInfo
  • "WARN": returns slog.LevelWarn
  • "ERROR": returns slog.LevelError

If the environment variable is not set or contains an invalid value, it returns the default level slog.LevelWarn.

func Log

func Log() *slog.Logger

Log returns a thread-safe singleton instance of slog.Logger configured for JSON output. If the logger hasn't been initialized, it creates a new instance with the log level specified by the environment. Further calls return the same logger instance.

Types

This section is empty.

Jump to

Keyboard shortcuts

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