feat: colored logging
This commit is contained in:
parent
385adb65db
commit
d9e047c517
15
main.go
15
main.go
@ -32,14 +32,19 @@ func (l *Logger) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
func (l *Logger) getMethodLogString(method string) string {
|
func (l *Logger) getMethodLogString(method string) string {
|
||||||
colorBlue := "\033[34m"
|
colorBlue := "\033[34m"
|
||||||
colorReset := "\033[0m"
|
colorReset := "\033[0m"
|
||||||
// colorRed := "\033[31m"
|
colorRed := "\033[31m"
|
||||||
// colorGreen := "\033[32m"
|
colorGreen := "\033[32m"
|
||||||
// colorYellow := "\033[33m"
|
colorYellow := "\033[33m"
|
||||||
// colorPurple := "\033[35m"
|
// colorPurple := "\033[35m"
|
||||||
// colorCyan := "\033[36m"
|
// colorCyan := "\033[36m"
|
||||||
// colorWhite := "\033[37m"
|
// colorWhite := "\033[37m"
|
||||||
if method == "GET" { return colorBlue + "GET" + colorReset }
|
switch method {
|
||||||
return method
|
case "GET": return colorBlue + "GET" + colorReset
|
||||||
|
case "POST": return colorGreen + "POST" + colorReset
|
||||||
|
case "DELETE": return colorRed + "DELETE" + colorReset
|
||||||
|
case "PUT": return colorYellow + "PUT" + colorReset
|
||||||
|
default: return method
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLogger(handler http.Handler) *Logger {
|
func NewLogger(handler http.Handler) *Logger {
|
||||||
|
Loading…
Reference in New Issue
Block a user