-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement SMTP client debug logging #102
Conversation
Resolves #101. Since we now have full control over the SMTP client we can also access the message input and output. This PR introduces a new debug logging feature. Via the `Client.WithDebugLog` the user can enable this feature. It will then make use of the new `smtp/Client.SetDebugLog` method. Once the flag is set to true, the SMTP client will start logging incoming and outgoing messages to os.Stderr. Log directions will be output accordingly
We don't want to expose SMTP authentication details in tests, therefore the tests have been adjusted a bit
Codecov Report
@@ Coverage Diff @@
## main #102 +/- ##
==========================================
- Coverage 81.05% 80.78% -0.28%
==========================================
Files 20 20
Lines 1837 1868 +31
==========================================
+ Hits 1489 1509 +20
- Misses 249 258 +9
- Partials 99 101 +2
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Instead of using the golang logger with not use an interface for the logger like for example:
with |
Good point. I'll check what would be the best option here. |
As stated in #102 (comment) it would be beneficial if, instead of forcing the Go stdlib logger on the user to provide a simple interface and use that for logging purposes. This PR implements this simple log.Logger interface as well as a standard logger that satisfies this interface. If no custom logger is provided, the Stdlog will be used (which makes use of the Go stdlib again). Accordingly, a `Client.WithLogger` and `Client.SetLogger` have been implemented. Same applies for the smtp counterparts.
As stated in wneessen/go-mail#102 (comment) it would be beneficial if, instead of forcing the Go stdlib logger on the user to provide a simple interface and use that for logging purposes. This PR implements this simple log.Logger interface as well as a standard logger that satisfies this interface. If no custom logger is provided, the Stdlog will be used (which makes use of the Go stdlib again). Accordingly, a `Client.WithLogger` and `Client.SetLogger` have been implemented. Same applies for the smtp counterparts.
Resolves #101.
Since we now have full control over the SMTP client we can also access the message input and output.
This PR introduces a new debug logging feature. Via the
Client.WithDebugLog
the user can enable this feature. It will then make use of the newsmtp/Client.SetDebugLog
method. Once the flag is set to true, the SMTP client will start logging incoming and outgoing messages to os.Stderr.Log directions will be logged accordingly.
C --> S
means Client to Server communicationC <-- S
means Server to Client communicationExample: