Challenge
When developing complex flows, it can be extremely important to have a clear understanding of how much time the entire process takes to complete, or even to break the process into several steps to understand how much time is spent on each step.
Since OutSystems doesn't have an out-of-box solution to accomplish this, we felt the need to have an accelerator that can be used in every project in a straightforward way and with minimum development effort.
Solution
The application DebugLogUtils offers two auxiliary actions to accomplish this easily, with no extra effort in terms of development.
You will only have to call the DebugLogStart at the beginning of the action/step and the DebugLogEnd at the end of the action/step. These actions will take care of calculating the duration and logging everything in the General Log.
The application has a site property to enable/disable the feature. Be aware that you should not have this enabled all the time, it should be enabled for debugging proposes and disabled afterward.
You can see an example of usage in the DebugLogUtilsDemo application, available in this forge component.
Sample usage of this patterns
The result in the General Log
Please note that the messages may not appear in the log in the correct order, this is due to the fact that the OutSystems logging mechanism does not guarantee the order of the messages. The Instant information mitigates this and will help you understand the correct order if needed. Nevertheless, if you use explicit Step messages the correct order will be clear for you.
Other solutions
We have found some solutions that address this need in the OutSystems Forge, but they lack some features we considered relevant, so we ended up developing this component to use in our projects.
https://www.outsystems.com/forge/component-overview/14664/extended-log
duration in seconds and not in milliseconds
doesn’t have the notion of start and end, you need to do this by hand
doesn’t allow disabling the mechanism
https://www.outsystems.com/forge/component-overview/6872/debug-time-log
doesn't log the start message
doesn't include the instant in the message