logger

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package logger provides a structured logging wrapper around go.uber.org/zap.

The logger is initialized with sensible defaults (JSON output, ISO8601 timestamps, Info level) and can be configured via environment variables or programmatically.

Usage:

import "bitbucket.org/jbjoret/commons/logger"

// Initialize from environment (optional, reads LOG_LEVEL env var)
logger.Init()

// Log messages
logger.Info("Application started", zap.String("version", "1.0"))
logger.Debug("Debug information", zap.Int("count", 42))
logger.Error("Something went wrong", zap.Error(err))

// Change log level programmatically
logger.SetLogLevel("debug")

// Get current log level
level := logger.GetLogLevel()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, fields ...zap.Field)

Debug prints a message at debug level.

func Error

func Error(msg string, fields ...zap.Field)

Error prints a message at error level.

func Fatal

func Fatal(msg string, fields ...zap.Field)

Fatal prints a message at fatal level, then calls os.Exit(1).

func GetLogLevel

func GetLogLevel() string

GetLogLevel returns the log level

func Info

func Info(msg string, fields ...zap.Field)

Info prints a message at info level.

func Init

func Init()

Init initializes the logger's level from the environment. It should be called after loading the .env file.

func SetLogLevel

func SetLogLevel(level string) error

SetLogLevel sets the log level based on a string.

func Warn

func Warn(msg string, fields ...zap.Field)

Warn prints a message at warn level.

Types

This section is empty.

Jump to

Keyboard shortcuts

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