Skip to content

Commit

Permalink
Merge pull request #43 from BugFixes/update-logger-logic-branch
Browse files Browse the repository at this point in the history
feat: Add condition to only log errors or successful requests
  • Loading branch information
Keloran authored May 13, 2024
2 parents 2126d21 + 8bd1ade commit 5186b6f
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 5186b6f

Please sign in to comment.