LogoTurboGo
Features

Logger

Structured and colorful request logging for TurboGo web apps.

Configure Logger

TurboGo includes a built-in structured logger that prints HTTP request logs in a clean and colorized format.
Logging is useful during development for observing route hits, debugging, and performance tracing.


Initialization

By default, logger is enabled automatically when the app starts:

func main() {
	app := TurboGo.New()
	app.Get("/", func(ctx *core.Context) {
		ctx.Text(200, "Hello, world!")
	})
}

To disable logging globally, set the following before starting the app:

func main() {
	core.DisableLogger = true // ๐Ÿ”‡ Turn off logging
	app := TurboGo.New()
	app.Get("/", func(ctx *core.Context) {
		ctx.Text(200, "Logging disabled!")
	})
}

๐Ÿ›ˆ Logging must be disabled before any request is handled.


How It Works

TurboGo's logger prints structured logs for each request with the following format:

๐ŸŒ€ TurboGo [05:50:35] GET / [200]

Each log includes:

  • โœ… Timestamp ([HH:MM:SS])
  • โœ… HTTP Method (GET, POST, etc.)
  • โœ… Path (/, /api, etc.)
  • โœ… Status code (e.g. [200], [404])
  • โœ… Colored output for improved readability

Example Log Output

๐ŸŒ€ TurboGo [12:03:11] GET /             [200]
๐ŸŒ€ TurboGo [12:03:13] POST /api/user    [201]
๐ŸŒ€ TurboGo [12:03:15] GET /not-found    [404]

Color coding:

  • 200โ€“299 โ†’ โœ… Green
  • 300โ€“399 โ†’ ๐Ÿ“˜ Cyan
  • 400โ€“499 โ†’ โš ๏ธ Yellow
  • 500โ€“599 โ†’ โŒ Red

Use Cases

  • ๐Ÿ‘€ Monitor HTTP traffic during development
  • ๐Ÿž Debug route access, timing, and status codes
  • โš™๏ธ Quickly spot routing errors or unexpected behavior
  • ๐Ÿงช Performance profiling and access audit