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โ โ Green300โ399โ ๐ Cyan400โ499โ โ ๏ธ Yellow500โ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