examples/

directory
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT

README

Velocity Examples

Runnable examples demonstrating velocity's features. Each example is a standalone main.go you can read, run, and modify.

Running

From this directory:

make run-basic              # or any target below
make run-all                # runs all examples sequentially
make help                   # list all targets

Or from the repo root:

go run ./examples/basic
go run ./examples/terminal-velocity

Examples

Getting Started
Example What it shows Run
basic Logger creation, log levels, typed fields, child loggers, SetLevel, InfoDetailed, presets make run-basic
json-logging Dual output (console + JSON file), WithCaller, custom time format, structured JSON make run-json
themes All four built-in colour themes (Night Owl, Solarized, Dracula, Nord) with the same log entries make run-themes
custom-theme Define your own colour palette (Cyberpunk neon). Shows how custom themes flow through loggers, pretty output, tables, and status indicators make run-custom-theme
Output and Display
Example What it shows Run
pretty-output Section, Box, Panel, Banner, Bullet, KeyValue, Table, Tree, SystemInfo, StatusFormatter make run-pretty
tables Table rendering with headers, rows, and ANSI-coloured cells (StatusFormatter) make run-tables
progress ProgressBar, all 5 Spinner styles, label changes, success/error stop messages make run-progress
Integration
Example What it shows Run
slog-bridge NewSlogLogger, slog.SetDefault, WithGroup, WithAttrs, level filtering make run-slog
multi-writer AddWriter/RemoveWriter, FilteredWriter, WriterFunc adapter make run-multi-writer
sampling CountSampler for high-volume log reduction, before/after stats make run-sampling
Showcase
Example What it shows Run
terminal-velocity Full GPU cluster deployment simulator using banner, spinners, progress bars, trees, tables, child loggers, structured fields, error recovery make run-terminal-velocity

Building

make build-all    # compiles all examples to examples/bin/
make clean        # removes compiled binaries

Directories

Path Synopsis
Package main demonstrates the basic usage of the velocity logging library.
Package main demonstrates the basic usage of the velocity logging library.
Custom theme example.
Custom theme example.
Package main demonstrates dual-output logging: coloured console for humans and newline-delimited JSON for log aggregators.
Package main demonstrates dual-output logging: coloured console for humans and newline-delimited JSON for log aggregators.
Multi-writer example.
Multi-writer example.
Package main demonstrates velocity's pretty-printing utilities for building rich CLI tool output.
Package main demonstrates velocity's pretty-printing utilities for building rich CLI tool output.
Progress bars and spinners example.
Progress bars and spinners example.
Sampling example.
Sampling example.
slog bridge example.
slog bridge example.
Package main demonstrates velocity's table rendering for structured terminal output.
Package main demonstrates velocity's table rendering for structured terminal output.
Terminal Velocity - GPU cluster deploy simulator.
Terminal Velocity - GPU cluster deploy simulator.
Package main cycles through velocity's four built-in themes so you can see how each one styles the different log levels.
Package main cycles through velocity's four built-in themes so you can see how each one styles the different log levels.

Jump to

Keyboard shortcuts

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