Logging all method calls in a Rails app

后端 未结 3 1076
太阳男子
太阳男子 2020-12-13 22:35

Is there an easy way to log all method calls in a Rails app?

My main use for this would be in testing (and in debugging tests). I want to have more of a history than

3条回答
  •  心在旅途
    2020-12-13 23:25

    Firstly stacktrace IS every method call that was on the stack at the time an error occurred, what other history could you want besides this?

    Secondly, to answer your question, no there is no easy way to log all method calls. You could up your log level all the way to debug which should give you more stuff in the logs, but this will only be things that someone has actually chosen to log, unrelated to method calls.

    It probably wouldn't be that difficult to patch ruby in such a way that every method call will print some log statements before and after the method execution, but this will once again be similar to what a stack trace would give you anyway and potentially less since you won't get line numbers etc.

    If you want more info than the stack trace, logging is the way most people would do it.

提交回复
热议问题