Skip to content

hamba/logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

abfe252 · Mar 28, 2025
Mar 28, 2025
Sep 1, 2023
May 26, 2021
Feb 11, 2019
Mar 28, 2025
Feb 12, 2025
Sep 1, 2023
Nov 12, 2022
Mar 16, 2022
Aug 5, 2022
May 14, 2021
May 14, 2021
Feb 12, 2025
Feb 12, 2025
Mar 10, 2025
Mar 10, 2025
Feb 12, 2025
May 21, 2024
May 14, 2021
May 14, 2021

Repository files navigation

Logo

Go Report Card Build Status Coverage Status Go Reference GitHub release GitHub license

logger is a fast Go logging package made to be simple but effective.

Overview

Install with:

go get github.com/hamba/logger/v2

Formatters

  • JSON
  • Logfmt
  • Console

Writers

  • SyncWriter Write synchronised to a Writer

Note: This project has renamed the default branch from master to main. You will need to update your local environment.

Examples

log := logger.New(os.Stdout, logger.LogfmtFormat(), logger.Info)

// Logger can have scoped context
log = log.With(ctx.Str("env", "prod"))

// All messages can have a context
log.Warn("connection error", ctx.Str("redis", "dsn_1"), ctx.Int("timeout", conn.Timeout()))

Will log the message

lvl=warn msg="connection error" env=prod redis=dsn_1 timeout=0.500

More examples can be found in the godocs.