My Application when running is writing logs. Now I need to check whether indexing is completed or not by checking for a status message as to whether it’s written in logs or not (note that logging is going on dynamically and the process is running). My application is not sending a signal as to when it has completed the process of indexing, just logs it and goes doing other stuff. Should I poll the logs continuously to check whether status has been written in logs but that would be kind of anti-pattern or bad design. I cant even have a busy-waiting or a do nothing loop and then check, another bad design. How can I check for the entered entry in logs in the best way without querying logs repetedly for that and with consuming less CPU cycles?
My Application when running is writing logs. Now I need to check whether indexing
Share
Polling is the usual solution. Other solutions require the
collaboration of the generating process in some way; if this is
possible, it’s obviously a preferable solution, but if the generating
process is to remain unaware of the listener (in the sense of not
knowing about its existance), then polling is about the only valid
solution. (Depending on the logging facilities, you might be able to
arrange for the log to go into a named pipe, and read that.)
Note that polling isn’t necessarily that expensive, if you aren’t doing
it too often.