lograge icon indicating copy to clipboard operation
lograge copied to clipboard

Question: How to filter just 200 OK for a given action

Open collimarco opened this issue 8 years ago • 2 comments

I have an endpoint /health for health checks. That action receives a lot of requests that are pretty useless in the logs.

Now I see that I can use

config.lograge.ignore_actions` = ['PagesController#health']

In that case, an exception would be logged? Because I would like to just filter the 200 OK, but not the errors.

  • Ideally I would like to log any status different from 200 OK. Is it possible?
  • If the above is not possible (e.g. any INFO [500] would be omitted), is it at least possible to log the exception itself raised by that action?

Thank you very much

collimarco avatar Aug 17 '17 09:08 collimarco

I'm looking to enact a similar process, did you find a solution?

KaraAJC avatar Jan 23 '19 15:01 KaraAJC

You can use something like this:

  config.lograge.ignore_custom = lambda do |e|
    # return true here if you want to ignore based on the event
    return true if e.payload[:status].try(:to_i).try(:<, 400) # ignore HTTP 1xx, 2xx, 3xx
    return false
  end

collimarco avatar Jan 23 '19 17:01 collimarco