Skip to content

feat: allow to customize log message#74

Open
sad-fat-cat wants to merge 1 commit intogo-chi:masterfrom
sad-fat-cat:feature/custom-log-message
Open

feat: allow to customize log message#74
sad-fat-cat wants to merge 1 commit intogo-chi:masterfrom
sad-fat-cat:feature/custom-log-message

Conversation

@sad-fat-cat
Copy link

New option LogFormat, that lets you control the format of the log messages

Copy link
Contributor

@VojtechVitek VojtechVitek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

},

LogFormat: func(r *http.Request, statusCode int, d time.Duration) string {
return fmt.Sprintf("%s %s => HTTP %v", r.Method, r.URL, statusCode)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity, what's the format you're thinking of for yourself?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just constant string, like "request processed".

Because all info about request already stored in slog attrs, and variance part in message field sort of difficult to work with aggregations (for example, % of uniq clients were affected by a particular error in this operation).

I thought about just putting the template string in the params, but the function seems more flexible, in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants