[PR #15] [MERGED] Add structured logging via logrus #59

Closed
opened 2026-02-26 18:33:12 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/decke/smtprelay/pull/15
Author: @JonathonReinhart
Created: 3/13/2021
Status: Merged
Merged: 3/13/2021
Merged by: @decke

Base: masterHead: structured-logging


📝 Commits (3)

  • 34cb47c Implement structured logs using logrus
  • 095fba1 Change default logfile to empty string (meaning stderr)
  • 9921b38 Explicitly configure default logfile for stderr

📊 Changes

6 files changed (+185 additions, -40 deletions)

View changed files

📝 config.go (+6 -1)
📝 go.mod (+2 -0)
📝 go.sum (+11 -0)
logger.go (+60 -0)
📝 main.go (+98 -37)
📝 smtprelay.ini (+8 -2)

📄 Description

This adds structured logging using logrus.

This PR is a result of discussions on #13 and is based loosely on grafana/smtprelay#10.

This adds two new config options to the INI file:

  • log_format which can be one of:
    • default -- The default logrus format, but with full timestamps, similar to the previous output:
      INFO[2021-03-13T00:54:21-05:00] listening on address                          address=":2525"
      
    • plain -- The default logrus format, but with no timestamps (useful for running under Systemd)
      INFO listening on address                          address=":2525"
      
    • json -- JSON formatting with RFC3339Nano timestamp format:
      {"address":":2525","level":"info","msg":"listening on address","time":"2021-03-13T00:56:40.251607698-05:00"}
      
  • log_level -- The logging level; defaults to "info" (can be panic, fatal, error, warn, info, debug, trace)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/decke/smtprelay/pull/15 **Author:** [@JonathonReinhart](https://github.com/JonathonReinhart) **Created:** 3/13/2021 **Status:** ✅ Merged **Merged:** 3/13/2021 **Merged by:** [@decke](https://github.com/decke) **Base:** `master` ← **Head:** `structured-logging` --- ### 📝 Commits (3) - [`34cb47c`](https://github.com/decke/smtprelay/commit/34cb47c36438ed4efe87c62dcdb64dc34d5e9e76) Implement structured logs using logrus - [`095fba1`](https://github.com/decke/smtprelay/commit/095fba119ac87958c93af8ff6cfe4ee6bf588054) Change default logfile to empty string (meaning stderr) - [`9921b38`](https://github.com/decke/smtprelay/commit/9921b380461b87d32b20691723d1aa82097a84f8) Explicitly configure default logfile for stderr ### 📊 Changes **6 files changed** (+185 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `config.go` (+6 -1) 📝 `go.mod` (+2 -0) 📝 `go.sum` (+11 -0) ➕ `logger.go` (+60 -0) 📝 `main.go` (+98 -37) 📝 `smtprelay.ini` (+8 -2) </details> ### 📄 Description This adds structured logging using [`logrus`](https://pkg.go.dev/github.com/sirupsen/logrus). This PR is a result of discussions on #13 and is based loosely on grafana/smtprelay#10. This adds two new config options to the INI file: - **`log_format`** which can be one of: - `default` -- The default `logrus` format, but with full timestamps, similar to the previous output: ``` INFO[2021-03-13T00:54:21-05:00] listening on address address=":2525" ``` - `plain` -- The default `logrus` format, but with no timestamps (useful for running under Systemd) ``` INFO listening on address address=":2525" ``` - `json` -- JSON formatting with RFC3339Nano timestamp format: ``` {"address":":2525","level":"info","msg":"listening on address","time":"2021-03-13T00:56:40.251607698-05:00"} ``` - **`log_level`** -- The logging level; defaults to "info" (can be panic, fatal, error, warn, info, debug, trace) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 18:33:12 +03:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/smtprelay#59
No description provided.