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 ¶
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 ¶
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.