logging

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package logging provides logging utilities for the application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForTestsOnlyResetLogger

func ForTestsOnlyResetLogger()

ForTestsOnlyResetLogger is for use in tests to reset the `sync.Once` mechanism. This allows the global logger to be re-initialized in different test cases. This function should not be used in production code.

func GetLogger

func GetLogger() *slog.Logger

GetLogger returns the shared global logger instance. If the logger has not yet been initialized through a call to `Init`, this function will initialize it with default settings: logging to `os.Stderr` at `slog.LevelInfo`.

Returns:

  • The global `*slog.Logger` instance.

func Init

func Init(level slog.Level, output io.Writer, format ...string)

Init initializes the application's global logger with a specific log level and output destination. This function is designed to be called only once, typically at the start of the application, to ensure a consistent logging setup.

Parameters:

  • level: The minimum log level to be recorded (e.g., `slog.LevelInfo`).
  • output: The `io.Writer` to which log entries will be written (e.g., `os.Stdout`).
  • format: Optional format string ("json" or "text"). Defaults to "text".

func ToSlogLevel

func ToSlogLevel(level configv1.GlobalSettings_LogLevel) slog.Level

ToSlogLevel converts a string log level to a slog.Level.

Parameters:

  • level: The log level from the configuration.

Returns:

  • The corresponding slog.Level.

Types

This section is empty.

Jump to

Keyboard shortcuts

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