tint

A zero-dependency slog.Handler for Go that writes tinted, colorized console logs.

Library
Go
vv1.2.0
1,346stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
55/100Fair
Development Activity40
Maintenance44
Community44
Maturity52
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
72/100Good
Architecture85
Code Quality92
Innovation55
Learning Curve55

tint implements a zero-dependency slog.Handler for Go’s standard-library log/slog package that writes tinted (colorized) logs to the console. Its output format is inspired by zerolog’s ConsoleWriter and slog’s own TextHandler, giving developers readable, color-coded local logs without pulling in a full third-party logging framework.

The handler exposes an Options struct that is a drop-in replacement for slog.HandlerOptions, supporting a configurable minimum level, custom time format, source-location output, and a ReplaceAttr hook for rewriting or dropping attributes before they’re logged. Individual attributes and errors can be tinted with specific ANSI colors via the tint.Attr and tint.Err helpers, and NoColor can disable coloring entirely for non-TTY output such as CI logs or piped files.

What You Get

  • A slog.Handler implementation (NewTextHandler) that writes tinted, colorized log lines to any io.Writer
  • An Options struct that mirrors slog.HandlerOptions, adding TimeFormat and NoColor fields for console-specific customization
  • tint.Attr and tint.Err helpers for coloring individual attributes and errors with a specific ANSI color
  • Full support for slog’s ReplaceAttr hook, WithAttrs, and WithGroup, so tint composes with existing slog-based code
  • Zero third-party dependencies — only the Go standard library is imported

Common Use Cases

  • Coloring local development logs to make level, time, and error attributes easier to scan at a glance
  • Replacing zerolog’s ConsoleWriter or a custom text formatter with a stdlib-native slog.Handler
  • Auto-detecting terminal capability with go-isatty to enable colors interactively but disable them when output is piped or redirected
  • Adding Windows ANSI color support to slog output via the go-colorable writer wrapper
  • Customizing or dropping specific attributes (like the time key) globally via ReplaceAttr before they reach the log line

Under The Hood

Architecture tint’s handler struct implements the four methods slog.Handler requires (Enabled, Handle, WithAttrs, WithGroup) in handler.go, holding attrsPrefix/groupPrefix/groups state plus a shared *sync.Mutex and io.Writer so that WithAttrs/WithGroup can clone() a lightweight derived handler without re-locking or duplicating the underlying writer. Handle() pulls a reusable byte buffer from a sync.Pool (buffer.go), appends time, level, optional source, message, and attributes in sequence — injecting ANSI escape sequences inline as it goes — then writes the finished line to the writer under the shared mutex, which is what keeps concurrent writes from clones interleaved correctly.

Tech Stack The module (go.mod, go 1.21+) depends on nothing but the Go standard library: log/slog for the handler contract, plus context, encoding, fmt, io, path/filepath, reflect, runtime, strconv, strings, sync, time, unicode, and unicode/utf8 for formatting and value inspection. There is no build step beyond go build; CI (.github/workflows/go.yml) runs gofmt, go vet, staticcheck, and go test -race with a faketime build tag for deterministic time-dependent assertions.

Code Quality The single handler_test.go file is extensive relative to the implementation’s size, with table-driven tests (TestHandler, TestHandler_Consistency, TestReplaceAttr, TestAttr), a dedicated concurrency test for mutex sharing across cloned handlers, runnable Example functions doubling as documentation, and benchmarks. Errors are surfaced rather than swallowed, and value-formatting panics (e.g. from a misbehaving TextMarshaler) are recovered and rendered explicitly rather than crashing the caller. CI enforces formatting, vetting, static analysis, and race-detected tests on every push and pull request.

What Makes It Unique tint’s niche is staying entirely inside the standard library’s logging story — rather than replacing log/slog with a separate framework like zerolog or zap, it’s just a Handler implementation, so any code already using log/slog gains colorized console output and per-attribute custom coloring (tint.Attr, tint.Err) by swapping one constructor call, with no additional dependencies or API to learn.

Used by 7 apps in this directory

Go
55%
Apache 2.0

Authgear

Authentication

2,014

Open-source, self-hostable authentication platform with passkeys, biometric login, SSO, MFA, and GraphQL admin API — a full Auth0/Clerk/Firebase alternative for SaaS and mobile apps.

View details
88
Repo Health
81
Technical
69
Dependency
Built with
Go55%
HTML25%
TypeScript17%
Updated 4 days ago
Rust
47%
MIT

Kuku

Note Taking

215

A local-first, open-source Markdown knowledge workspace for macOS — plain files, personal wiki and Second Brain workflows, AI-assisted diffs, and encrypted sync, built as an Obsidian alternative.

View details
73
Repo Health
67
Technical
67
Dependency
Built with
Rust47%
TypeScript40%
Updated 2 months ago
Go
56%
Other

Multica

AI Assistants · AI Development

48,263

Turn coding agents into real teammates — assign issues, track progress, and compound reusable skills across a vendor-neutral, self-hosted platform.

View details
86
Repo Health
83
Technical
70
Dependency
Built with
Go56%
TypeScript39%
Updated today
Go
44%
GPL 3.0

Netdata

Monitoring · Devops

80,357

Real-time per-second metrics, ML-powered anomaly detection, and zero-config observability for any infrastructure.

View details
93
Repo Health
86
Technical
71
Dependency
Built with
Go44%
C32%
Rust15%
Updated today
Go
78%
Apache 2.0

OpenMeter

Invoicing Finance · Developer Tools

2,236

Open-source metering and billing engine for AI, agentic, and DevTool monetization — ingest usage events in real time and turn them into accurate invoices automatically.

View details
86
Repo Health
81
Technical
66
Dependency
Built with
Go78%
TypeScript17%
Updated 2 days ago
Go
75%
AGPL 3.0

Teleport

Security · Authentication

20,860

Zero-trust infrastructure access platform that replaces credentials and VPNs with short-lived certificates, SSO, and identity-aware proxies for SSH, Kubernetes, databases, RDP, and AI agents.

View details
94
Repo Health
81
Technical
69
Dependency
Built with
Go75%
TypeScript16%
Updated 2 days ago
Go
85%
Apache 2.0

Uncloud

Devops

5,470

Deploy and scale containerised apps across any servers without Kubernetes or Swarm overhead

View details
83
Repo Health
78
Technical
66
Dependency
Built with
Go85%
Updated 2 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search