I am writing a program to read a log file. each entry starts with a time-stamp, except when there is an error, which in this case, I would have multiple lines for the error message and without time-stamp.
The file looks like this:
20190207 14:23:10.123 info Read input
20190207 14:23:11.001 info connecting to database
20190207 14:23:17.101 error truncating the table customer. Error code XXXX
the file was blocked.
I would like to store every entry with its time-stamp, event type, and message in a table that has three columns, one column for the time-stamp (datetime) and another column for the events (info/warning/error), and a column for the text (data type text).
How do I iterate through the file and read all the entries including the error message which sometimes be in multiple lines?