File size: 436 Bytes
a8ebadf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package middlewares

import (
	"log"
	"time"
	"net/http"

	"github.com/gofiber/fiber/v2"
)


/*
 *  --- Logging Middleware ---
*/
func LoggingMiddleware(c *fiber.Ctx) error {
	start_time := time.Now()

	log.Printf("[%s] %s %s - %d %s in %v",
		time.Now().Format("2006-01-02 15:04:05"),
			c.Method(), c.Path(), c.Response().StatusCode(),
				http.StatusText(c.Response().StatusCode()), time.Since(start_time))

				
	return c.Next()
}