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 Var | Values | Behavior |
|---|---|---|
LOG_TYPE | terminal (default), file, both / all | Writes to stdout/TUI, LOG_PATH file, or both via zerolog.MultiLevelWriter. |
LOG_LEVEL | trace, debug, info (default), warn, error, fatal, panic | Global zerolog level. |
LOG_PATH | e.g. storage/logs/app.log | File destination when LOG_TYPE is file or both (parent dirs created automatically). |
LOG_FORMAT | log (default), json, yaml | log uses prettyWriter; json emits structured JSON (yaml falls back to JSON). |
LOG_COLOR | auto (default), always, never | Controls 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:
<100msgreen,<500msyellow,>=500msred. - Sorts
key=valuefields witherrorfirst and multilinestacklast. core/console/colors.goprovides 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-tuiis not setLOG_TYPEincludes terminal (terminal,both,all) andLOG_FORMATis notjson/yamlstdinandstdoutare interactive TTYsTERM != "dumb"andCI == ""
Features & Captured Streams
- Captures zerolog output,
os.Stdout/os.Stderr(viaos.Pipe+ scanner), Gin writers, stdliblog, andgormlogger.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, plusSystem. - 5,000-entry ring buffer per dashboard session; prints the last 30 lines to stdout on exit.
Keyboard Shortcuts
| Key | Action |
|---|---|
Tab / ← / → / h / l | Cycle sidebar panels |
1 – 9 | Jump directly to panel N |
↑ / ↓ / j / k | Scroll up / down one line |
PgUp / PgDn / b / Space / Ctrl+U / Ctrl+D | Page / half-page scroll |
g / Home / G / End | Jump to top / bottom |
f | Toggle auto-follow |
c | Clear current panel |
m | Toggle mouse capture |
q / Ctrl+C | Graceful shutdown (press twice to force quit) |
