-
Notifications
You must be signed in to change notification settings - Fork 105
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
Add structured logging via logrus #15
Conversation
@dannykopping Please take a look and let me know if this doesn't work for you guys. Aside from obvious log location or message changes due to the various refactorings, this differs from what you have in the following ways:
I think you should be able to run with the nearly equivalent functionality as before with this INI snipppet:
|
var smtpError smtpd.Error | ||
|
||
switch err.(type) { | ||
case *textproto.Error: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! In which kind of error situation does SendMail return this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't take credit for this; it was taken straight from #13. But in my testing I have seen:
ERRO[2021-03-13T02:47:27-05:00] delivery failed err_code=530 err_msg="5.7.0 Authentication Required. Learn more at\n5.7.0 https://support.google.com/mail/?p=WantAuthError h75sm6304163qke.80 - gsmtp" from=jreinhart@jrr-vaio host="smtp.gmail.com:587" peer=127.0.0.1 to="[jonathon.reinhart@gmail.com]" uuid=ada212ce-ca9d-4a2b-923a-830ce6f19e37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dannykopping do you know in which situation SendMail returns this error? I can check myself later but need a bigger screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good @JonathonReinhart - thanks for taking the time to do this!
Left a couple thoughts but overall happy with it, and kind of you to add this for us to maintain our current behaviour:
I think you should be able to run with the nearly equivalent functionality as before with this INI snipppet:
ea4cb1c
to
56ef9a7
Compare
This was based loosely on an earlier implementation by Danny Kopping <danny.kopping@grafana.com>
The causes logrus to write to stderr.
45dbfef
to
9921b38
Compare
Okay this should be ready to go now if @decke is happy with my updates. |
Thanks a lot guys! It was a pleasure to see how opensource can benefit us all. |
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 defaultlogrus
format, but with full timestamps, similar to the previous output:plain
-- The defaultlogrus
format, but with no timestamps (useful for running under Systemd)json
-- JSON formatting with RFC3339Nano timestamp format:log_level
-- The logging level; defaults to "info" (can be panic, fatal, error, warn, info, debug, trace)