<commit_before>package logger

import (
	"github.com/gin-gonic/gin"
)

// SetLogger initializes the logging middleware.
func SetLogger() gin.HandlerFunc {
	return gin.Logger()
}<commit_msg>Customized logger middleware like ginrus<commit_after>package logger

import (
	"time"

	"github.com/Sirupsen/logrus"
	"github.com/gin-gonic/gin"
)

// SetLogger initializes the logging middleware.
func SetLogger() gin.HandlerFunc {
	return func(c *gin.Context) {
		start := time.Now()
		path := c.Request.URL.Path

		c.Next()

		end := time.Now()
		latency := end.Sub(start)

		entry := logrus.WithFields(logrus.Fields{
			"status":     c.Writer.Status(),
			"method":     c.Request.Method,
			"path":       path,
			"ip":         c.ClientIP(),
			"latency":    latency,
			"user-agent": c.Request.UserAgent(),
			"time":       end.Format(time.RFC3339),
		})

		if len(c.Errors) > 0 {
			entry.Error(c.Errors.String())
		} else {
			entry.Info("requested")
		}
	}
}
{'fraction_non_alphanumeric': 0.1581151832460733, 'fraction_numerical': 0.005235602094240838, 'mean_word_length': 3.211453744493392, 'pattern_counts': {'":': 7, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7569748', 'n_tokens_mistral': 384, 'n_tokens_neox': 342, 'n_words': 66}