Skip to content

axiomhq/logmanager

Repository files navigation

logmanager Go Reference Workflow Latest Release License

Yet another Go logging library with a focus on simplicity and flexibility.

Install

go get github.com/axiomhq/logmanager

Usage

package main

import (
    "github.com/axiomhq/logmanager"
)

func main() {
    // Simple console logger
    log := logmanager.GetLogger("foo.bar")
    log.Info("hello world")
    log.Warn("it's a trap")

    // Output:
    // [09:15:54.24] info  [email protected] main.go:10 hello world
    // [09:15:54.24] warn  [email protected] main.go:11 it's a trap
}

Features

  • Multiple log levels (Trace, Debug, Info, Warning, Error, Critical)
  • Colored console output with automatic color assignment per module
  • File-based logging with automatic rotation
  • Syslog support (RFC 5424)
  • Thread-safe operations
  • Module-based logging with inheritance
  • Stack trace support for errors and panics
  • Zero dependencies for core functionality

Configuration

Set log levels via environment variable:

# Set specific module log levels
export LOGMANAGER_SPEC="foo.bar=Debug:foo=Trace:Info"

# Set global log level
export LOGMANAGER_SPEC="Debug"

Writers

logmanager supports multiple output writers:

Console Writer

Outputs colored logs to stdout/stderr with automatic color assignment per module.

writer := logmanager.NewConsoleWriter()
logmanager.AddGlobalWriter(writer)

Disk Writer

Writes logs to files with automatic rotation support.

writer := logmanager.NewDiskWriter("/var/log/app.log", logmanager.DiskWriterConfig{
    RotateDuration:  24 * time.Hour,
    MaximumLogFiles: 7,
})
logmanager.AddGlobalWriter(writer)

Syslog Writer

Sends logs to syslog (RFC 5424 format).

writer := logmanager.NewSyslogWriter("myapp", "127.0.0.1:514")
logmanager.AddGlobalWriter(writer)

License

MIT

About

Yet another Go logging library.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 5