-
-
Notifications
You must be signed in to change notification settings - Fork 136
Description
We've just migrated to semantic_logger recently. It's been working rather well most of the time so far.
One thing that was surprising is how it treats payload.exception. In our previous integration using lograge, we used to pass an :exception object in append_info_to_payload´, which we decomposed to class and message in the json message later on. We saw that vanilla semantic logger does the same by design when, using log.error(msg, ctx, ex), the 3rd argument is json-formatted into an hash of :message, :nameand:stack_trace`, even going to the trouble of traversing the "cause tree" to expose that.
That does not work with action controller however. For instance, given the following code:
class ApplicationController < ActionController::Base
def append_info_to_payload(payload)
if @exception_i_want_to_log
payload[:exception] = @exception_i_want_to_log
end
end
endthe exception will never be logged, because of this. In order to keep the old behaviour, we had to reimport the old logic of formatting the exception ourselves in the payload.
I think this could be self-served via semantic logger. Any reason why that exception can't be logged? I see it's used to infer some http status code from rails, but I haven't seen a great use for it. I wonder whether, by removing that snippet, one could stop breaking the principle of least surprise?