log

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package log provides application-level logging functionality for services.

This package creates and configures loggers with appropriate settings based on the environment (production or non-production) and service name. It offers a simplified API for initializing loggers with appropriate defaults:

- In non-production environments: Debug level with readable text output - In production environments: Info level with structured JSON output - Automatic caller information and stack traces for errors - Service name and environment included as additional fields in all log entries

This package is intended to be the primary entry point for applications using the logger package, providing a simple way to create well-configured loggers that follow best practices for different environments.

Usage:

log, err := log.New(ctx, "development", "user-service")
if err != nil {
	panic(err)
}

log.Info("Service started successfully")
log.WithField("user", userID).Debug("User authenticated")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWithDefaults

func NewWithDefaults(ctx context.Context, environment string, service string) (hyperlogger.Logger, error)

NewWithDefaults creates a new logger instance with the specified environment and service. It configures the logger with a console writer, time format, caller information, and additional fields for the service and environment. If the environment is non-production, the logger is set to debug level. Otherwise, it is set to info level with JSON output. The function returns the created logger instance and any error that occurred during initialization.

Types

This section is empty.

Jump to

Keyboard shortcuts

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