Skip to content
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

Allow to customize a message of action log #240

Merged

Conversation

y-yagi
Copy link
Contributor

@y-yagi y-yagi commented Sep 27, 2024

Issue # (if available)

Fixes #149.
An alternative of #215.

Description of changes

Currently, a message of action log is a fixed value. Some services(e.g. Datadog) emphasize a message value. So sometimes we want to add more information to that column.

This PR adds the config to customize that value. We can change the value like the following.

config.rails_semantic_logger.action_message_format = -> (message, payload) do
  "#{message} - #{payload[:controller]}##{payload[:action]}"
end

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Currently, a message of action log is a fixed value.
Some services(e.g. Datadog) emphasize a `message` value. So
sometimes we want to add more information to that column.

This PR adds the config to customize that value. We can change the
value like the following.

```ruby
config.rails_semantic_logger.action_message_format = -> (message, payload) do
  "#{message} - #{payload[:controller]}##{payload[:action]}"
end
```
@reidmorrison
Copy link
Owner

Excellent idea, thank you @y-yagi

@reidmorrison reidmorrison merged commit f8f1084 into reidmorrison:master Sep 29, 2024
12 checks passed
@y-yagi y-yagi deleted the allow_to_customize_log_message branch September 29, 2024 23:34
@glaucocustodio
Copy link

Cool, any plans for a new gem release @reidmorrison?

@kucho
Copy link

kucho commented Dec 7, 2024

Any chance we get a release soon @reidmorrison? 🙏

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.

[Feature Request] Ability to modify log message
4 participants