Skip to content

Using log_tags with rake tasks #145

@dgmora

Description

@dgmora

Environment

Provide at least:

  • Ruby Version. 2.6.8
  • Rails Version. 5.2.6
  • Semantic Logger Version. 4.8.2
  • Rails Semantic Logger Version. 4.6.1
  • Rails configuration. Only need the settings related to Rails Semantic Logger and Semantic Logger.
# application.rb
config.log_tags = {
  request_id: ->(request) { request.uuid }
  something: 'else'
}
config.rails_semantic_logger.format = SomeFormatter.new

Expected Behavior

named_tags are also applied to rake tasks, or there's a way to configure that (I have not found how to do it)

Actual Behavior

I am using semantic logger to log in json. That part is working correctly also with rake. However the log_tags are not attached and it seems that the custom formatter I use isn't used neither. I think that with rails the log_tags are evaluated once per request, and that's probably the cause for them not being used, but I was wondering what would be an appropriate solution

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions