To explain in detail, I have a text file in which I am logging some data from a varying number of process instances(i.e there could be between 4 to 16 process instances generating the logs).
All the instances write into one file in the following format:
2018-09-07 11:34:47,251 - AppLog - INFO -
******************************************
Log Report - Consume Cycle jhTyjs-ConsumeCycle
******************************************
Uptime: 144708.62724542618s
Jobs Run: 16866
Jobs Current: 1
Q Avg Read Time: 0
Q Msgs Read: 0
Worker Load: ['1.00', '1.00', '1.00']
******************************************
2018-09-07 11:37:47,439 - AppLog - INFO -
******************************************
Log Report - Consume Cycle aftTys-ConsumeCycle
******************************************
Uptime: 144888.81490063667s
Jobs Run: 16866
Jobs Current: 1
Q Avg Read Time: 0
Q Msgs Read: 0
Worker Load: ['1.00', '1.00', '1.00']
******************************************
This is an error line which could be generated by any of the instances and can be anything, <br> like qfuigeececevwovw or wefebew efeofweffhw v wihv or any python \n exception or aiosfgd ceqic eceewfi
2018-09-07 11:40:47,615 - AppLog - INFO -
******************************************
Log Report - Consume Cycle hdyGid-ConsumeCycle
******************************************
Uptime: 145068.99103808403s
Jobs Run: 16866
Jobs Current: 1
Q Avg Read Time: 0
Q Msgs Read: 0
Worker Load: ['1.00', '1.00', '1.00']
******************************************
(In Log Report - Consume Cycle [placeholder]-ConsumeCycle
of every log, the [placeholder]
is random)
So, my file consists of a large number of logs in the above format, one after another. Every instance generates the log in every 3 minutes.
(i.e all the instances generate exactly one log in 3 minutes)
If there is an error from any of the instances, they log that as well in the same file. So the data structure is not at all consistent.
Now, I have to get the last logged data i.e last 3 minutes from all of the instances and perform some tasks on them.
Is there any way to get the last 3 minutes data written into the log file (be it errors or perfect logs in the above format)?
[EDIT] Added an error line in between the logs