1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-24 04:04:02 +00:00
Fenny ea129d02ab 🎨 add colors to default format
Co-Authored-By: Yuil Tripathee <28005756+YuilTripathee@users.noreply.github.com>
2020-09-29 20:40:10 +02:00

40 lines
779 B
Go

package logger
import (
"github.com/gofiber/fiber/v2"
)
func methodColor(method string) string {
switch method {
case fiber.MethodGet:
return cCyan
case fiber.MethodPost:
return cGreen
case fiber.MethodPut:
return cYellow
case fiber.MethodDelete:
return cRed
case fiber.MethodPatch:
return cWhite
case fiber.MethodHead:
return cMagenta
case fiber.MethodOptions:
return cBlue
default:
return cReset
}
}
func statusColor(code int) string {
switch {
case code >= fiber.StatusOK && code < fiber.StatusMultipleChoices:
return cGreen
case code >= fiber.StatusMultipleChoices && code < fiber.StatusBadRequest:
return cBlue
case code >= fiber.StatusBadRequest && code < fiber.StatusInternalServerError:
return cYellow
default:
return cRed
}
}