Skip to content

Logging & Interactive TUI Dashboard ​

core/console integrates zerolog, a custom colorized prettyWriter, Gin debug route redirection, and a full-screen Bubble Tea TUI Dashboard.


Zerolog Configuration (core/console/logger.go) ​

initLogger(cfg.Log) runs in PersistentPreRunE, and closeLogger() closes any open log file handle in PersistentPostRun.

Env VarValuesBehavior
LOG_TYPEterminal (default), file, both / allWrites to stdout/TUI, LOG_PATH file, or both via zerolog.MultiLevelWriter.
LOG_LEVELtrace, debug, info (default), warn, error, fatal, panicGlobal zerolog level.
LOG_PATHe.g. storage/logs/app.logFile destination when LOG_TYPE is file or both (parent dirs created automatically).
LOG_FORMATlog (default), json, yamllog uses prettyWriter; json emits structured JSON (yaml falls back to JSON).
LOG_COLORauto (default), always, neverControls ANSI colors; also respects NO_COLOR, FORCE_COLOR, and TERM=dumb.

prettyWriter & Gin Redirect ​

  • Formats "HTTP Request", "gRPC Request", and "Route" (setupGinDebugOutput()) in compact aligned layouts.
  • Colors latencies: <100ms green, <500ms yellow, >=500ms red.
  • Sorts key=value fields with error first and multiline stack last.
  • core/console/colors.go provides CLI helpers: Success, Error, Info, Warning, Color.

Interactive TUI Dashboard (core/console/dashboard.go) ​

When running serve (or goforge app serve), GoForge launches a full-screen Bubble Tea TUI automatically if all of these hold:

  • --no-tui is not set
  • LOG_TYPE includes terminal (terminal, both, all) and LOG_FORMAT is not json/yaml
  • stdin and stdout are interactive TTYs
  • TERM != "dumb" and CI == ""

Features & Captured Streams ​

  • Captures zerolog output, os.Stdout/os.Stderr (via os.Pipe + scanner), Gin writers, stdlib log, and gormlogger.Default.
  • Sidebar panels: All logs, one live panel per active server (HTTP/HTTPS, gRPC) showing status (starting, running, stopping, stopped, failed), listen address, and request/route/error counters, plus System.
  • 5,000-entry ring buffer per dashboard session; prints the last 30 lines to stdout on exit.

Keyboard Shortcuts ​

KeyAction
Tab / ← / → / h / lCycle sidebar panels
1 – 9Jump directly to panel N
↑ / ↓ / j / kScroll up / down one line
PgUp / PgDn / b / Space / Ctrl+U / Ctrl+DPage / half-page scroll
g / Home / G / EndJump to top / bottom
fToggle auto-follow
cClear current panel
mToggle mouse capture
q / Ctrl+CGraceful shutdown (press twice to force quit)

Released under the Apache-2.0 License.