I am thinking about where to write a journal entry around the operation. Here are two different styles. First, write down the journal before the operation.
Before:
log.info("Perform operation XXX") operation()
And here is another style, write a magazine after surgery.
After:
operation() log.info("Operation XXX is done.")
Using the before-style, the log entries say what to do now. About this style is that when something goes wrong, the developer can easily find it, because they know what the program is doing now. But con is that you are not sure that the operation is completed correctly, if something is wrong inside the operation, for example, a function call is blocked and never returns, you cannot know this by reading the logging entries. After completing the style, you are sure that the operation is complete.
Of course we can mix these two styles together
AND
log.info("Perform operation XXX") operation() log.info("Operation XXX is done.")
But I feel that this is a bit detailed, it is recording with double logging. So here is my question: what is a good journal style? I would like to know what you think.
Thanks.
source share