mozilla-services / slog-mozlog-json

MozLog JSON drain for slog-rs
Mozilla Public License 2.0
2 stars 4 forks source link

Reusable request summary logger? #3

Open leplatrem opened 5 years ago

leplatrem commented 5 years ago

I'm integrating slog-mozlog-json with actix-web, and I realize that I'll duplicate a lot of code from: https://github.com/mozilla-services/megaphone/blob/e8e024574856413f2db7120b51c6f8e0adf42c8d/src/logging.rs#L29-L63

Wouldn't it make sense to have MozLogFields in this library?

We could have something like this, in our integrations:

impl From<Request> for MozLogFields {
    fn from(Request) -> Self {
        MozLogFields {
            method: request.method().as_str(),
            ...
        }
    }
}
pjenvey commented 5 years ago

This seems reasonable to save the need for a KV impl. -- but while pondering this I've discovered slog_derive.

With that I'm leaning towards no, let's not bother including a Fields struct. These mozlog fields can certainly vary among apps, anyway. Thoughts?