Tag the first line in the log

I try to calculate times of all kinds of device actions through the log. I would also like to calculate the time from the beginning of the log to a certain line appearance, and from a certain line appearance to the end of the log. I can tag the lines, but the log may start and end differently. I want to tag the first line and the end line in the log, how can I do that?
Thank you!