Fixing one last problem detected with logging
There’s a big reason why I choose to build a logging library in Part 2, Logging Library, of this book. Logging can be a huge help when debugging known problems. Something that’s often overlooked is the benefit that logging provides when looking for bugs that haven’t been detected yet.
I’ll often look at the log file after running tests to make sure the messages match what I expect. After making the enhancements in the previous section for the thread coordination between the test and the test calculation thread, I noticed something strange in the log file. The log file looks like this:
2022-08-27T05:00:50.409 Service is starting.
2022-08-27T05:00:50.410 user="123" Received Calculate request for: 5
2022-08-27T05:00:50.411 user="123" Received Calculate request for: 5
2022-08-27T05:00:50.411 user="123" Received Status request for: 1
2022-08-27T05:00:50.411 Service is starting....