Giter Site home page Giter Site logo

Comments (7)

nzifnab avatar nzifnab commented on July 25, 2024

Having the same problem here. The problem is that append_info_to_payload is only run by Rails at the end of the action, and never gets run if there was an exception.

It can be hackishly-solved by monkey-patching actionpack/action_controller/metal/instrumentation.rb's process_action method to run append_info_to_payload before calling super, but I really don't like this solution. Is there another way to get custom values into the log hash from the controller-level?

I was even considering trying to add an event listener for the process_action.action_controller event, have it run before the one that LogRage defines, and add custom info to the payload there - but I don't think that'll work because LogRage does a clean sweep of all of those listeners and clears them out.

I'm at a bit of a loss :(

from lograge.

mxrguspxrt avatar mxrguspxrt commented on July 25, 2024

From your log it seems that in somewhere in your code you try to access some models ID, but it is a nil object, and it will cause exception.

It is a Rails issue that when exception is called, #append_info_to_payload is not called. Source:

https://github.com/rails/rails/blob/ebfd97124db0cd7550dd197559343e2fda5b79d6/actionpack/lib/action_controller/metal/instrumentation.rb#L33

I am making issue and a pull request as I write this. :)

from lograge.

neilberget avatar neilberget commented on July 25, 2024

Is the monkey-patching solution mentioned by @nzifnab the best work around in the meantime?

from lograge.

mxrguspxrt avatar mxrguspxrt commented on July 25, 2024

He recommended that #append_info_to_payload is called before process_action, what sounds to be a bad idea and he also admitted it. It is bad, because your controller has not done it's stuff and processing result is not available at that moment.

Monkeypatching is also bad. I think you could overwrite your ApplicationController#process_action and ensure that if exception is risen you still call #append_info_to_payload

rails/rails#14903

from lograge.

kommen avatar kommen commented on July 25, 2024

FYI, this is now fixed in rails. rails/rails#17978

from lograge.

benlovell avatar benlovell commented on July 25, 2024

❤️

from lograge.

nicholasmott avatar nicholasmott commented on July 25, 2024

Awesome.

from lograge.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.