Help us shape the future of Go! Take the 2026 Go Developer Survey

go-logger

module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT

README

Go Logger

A small structured logging library for Go with pluggable sinks and predictable runtime behavior.

Features

  • Structured Fields: Attach contextual key/value pairs to every entry.
  • Pluggable Sinks: Send logs to the console, rotating files, Prometheus-style counters, Telegram, or custom integrations.
  • Derived Loggers: Bind shared fields with With(...) and reuse them across call sites.
  • Runtime Level Control: Adjust log verbosity without rebuilding your application.

Installation

go get github.com/mirkobrombin/go-logger

Quick Start

package main

import "github.com/mirkobrombin/go-logger/pkg/logger"

func main() {
    lg := logger.New()
    lg.Info("service started", logger.Field{Key: "port", Value: 8080})

    requestLogger := lg.With(logger.Field{Key: "request_id", Value: "abcd"})
    requestLogger.Info("handling request")
}

Documentation

Rotating File Sink

package main

import "github.com/mirkobrombin/go-logger/pkg/logger"

func main() {
    sink, err := logger.NewRotatingFileSink("var/log/my-app.log", logger.RotatingFileOptions{
        MaxSizeMB:  50,
        MaxBackups: 7,
        MaxAgeDays: 14,
        Compress:   true,
    })
    if err != nil {
        panic(err)
    }
    defer sink.Close()

    lg := logger.New(logger.WithSink(sink))
    lg.Info("file logging enabled")
}

License

This project is licensed under the MIT License. See the LICENSE file for details.

Directories

Path Synopsis
examples
http command
pkg

Jump to

Keyboard shortcuts

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