Skip to content

Commit

Permalink
feat: Add condition to only log errors or successful requests
Browse files Browse the repository at this point in the history
Added a condition to only log errors or successful requests with a status of 200. This helps to filter out unnecessary log entries and focus on the most important information.
  • Loading branch information
Keloran committed May 13, 2024
1 parent 2126d21 commit 8bd1ade
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion middleware/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ func (l *defaultLogEntry) Write(status, bytes int, elapsed time.Duration) {
cW(l.buf, l.useColor, nRed, "%s", elapsed)
}

if l.LogLevel >= Info {
if status == 200 {
if l.LogLevel <= Error {
l.Logger.Print(l.buf.String())
}
} else {
l.Logger.Print(l.buf.String())
}
}
Expand Down

0 comments on commit 8bd1ade

Please sign in to comment.