log

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

README

log

A thin structured logging wrapper over Zap, shared by both the API server and the agent. It is initialized automatically on import with no configuration required and has no internal project dependencies, making it safe to import anywhere. All log output is JSON-encoded. Logs always go to stdout; if a log file path is set via environment variable, they are also appended to that file. Every process instance is tagged with a unique identifier at startup so log entries from different restarts can be correlated in aggregated output.

Exports severity-level logging functions covering debug, info, warn, error, and panic. Each accepts a message string followed by any number of key-value pairs, which are included as extra fields in the structured JSON output. Unpaired keys are silently ignored. The panic-level function calls Go's built-in panic after logging, which is safe in route handlers and database functions because the recovery middleware catches it.

Documentation

Overview

Package log configures a global logger and exports common logging functions. It is a very light wrapper over Zap. This logger utilizes an init() function and has no internal dependencies. This makes it easy to import and start using. Logs are always written to stdout. If the QU_LOG_FILE environment variable is set, logs are also appended to that file. Each process instance is tagged with a unique "restart" UUID so log entries can be correlated across restarts. This package might need more environment variables to configure some common settings, like log level and stack traces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, keysAndValues ...any)

Debug logs a message with level == 'debug'. Takes arbitrary key value pairs which are added as extra fields in the output.

log.Debug(
  "nothing happened",  // message
  "honk", "mimimimi",  // key value pairs
  "number", 1,
  "key_without_value", // ignored
)

func Error

func Error(msg string, keysAndValues ...any)

Error logs a message with level == 'error'. Takes arbitrary key value pairs which are added as extra fields in the output.

log.Error(
  "something failed",  // message
  "error", err,        // key value pairs
  "number", 3,
  "key_without_value", // ignored
)

func Info

func Info(msg string, keysAndValues ...any)

Info logs a message with level == 'info'. Takes arbitrary key value pairs which are added as extra fields in the output.

log.Info(
  "something happended", // message
  "nothing", "gets",     // key value pairs
  "past", "my bow!",
  "key_without_value",   // ignored
)

func Panic

func Panic(msg string, keysAndValues ...any)

Panic logs a message with level == 'panic'. It immediately calls panic() after. This is safe to call in DB functions and Gin Routes; the recovery middleware will handle it. Takes arbitrary key value pairs which are added as extra fields in the output.

log.Panic(
  "i died",            // message
  "error", err,        // key value pairs
  "number", 4,
  "key_without_value", // ignored
)

func Warn

func Warn(msg string, keysAndValues ...any)

Warn logs a message with level == 'warn'. Takes arbitrary key value pairs which are added as extra fields in the output.

log.Warn(
  "something weird",   // message
  "error", err,        // key value pairs
  "number", 2,
  "key_without_value", // ignored
)

Types

This section is empty.

Jump to

Keyboard shortcuts

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