Loq: Logging for Humans, using the slog framework

When I started using Go, I was disappointed to find that its logging facilities lack features that I have come to expect from modern languages and their standard libraries. The log package is so basic that one might as well just use Println. The slog package is heavily geared for machine-parsed logs, which might be great for high-volume enterprisey projects, but it has no support for the traditional formatting, highlighting, or filtering that work well for local users and admins.

I wrote loq to address these shortcomings.

It’s built with slog’s interfaces and semantics, for compatibility, but is designed to make logging easier for human developers and users, especially in stand-alone software.

Here’s an excerpt from the readme, the full version of which includes a tour of the main features (with examples):

Highlights:

  • Uncluttered line-oriented output

  • Printf-style message formatting

  • Color coding by severity level

  • Named severity levels beyond those defined by slog

  • Handler trees with inheritable severity levels

The handlers and wrappers in loq are interchangeable parts that can be used with each other, combined with slog types, or passed to code that accepts slog types. In many cases, they are also faster than what slog offers.

The only dependencies are from Go’s standard library and X-Repositories.