Features
Logger
Request logging for Ply applications.
Configure Logger
Ply includes a request logger that prints one line per request with colored status codes. It is useful during development for observing route hits, debugging and performance tracing.
Initialization
The logger is enabled automatically when the app starts:
func main() {
app := ply.New()
app.Get("/", func(ctx *core.Context) {
ctx.Text(200, "Hello, world!")
})
}To disable logging globally, set the flag before starting the app:
func main() {
core.DisableLogger = true // disable logging
app := ply.New()
app.Get("/", func(ctx *core.Context) {
ctx.Text(200, "Logging disabled")
})
}Logging must be disabled before any request is handled.
Output format
Ply [05:50:35] GET / [200]Each line contains:
- Timestamp (
[HH:MM:SS]) - HTTP method (
GET,POST, and others) - Path (
/,/api, and others) - Status code (
[200],[404], and others) - Color applied to the status code
Example output:
Ply [12:03:11] GET / [200]
Ply [12:03:13] POST /api/user [201]
Ply [12:03:15] GET /not-found [404]Status colors:
200-299: green300-399: cyan400-499: yellow500-599: red
Use cases
- Monitoring HTTP traffic during development
- Debugging route access, timing and status codes
- Locating routing errors and unexpected behavior
- Auditing access during performance work

Ply