I have a log file with such data inside:
2020-07-28 10:07:01 (pool-3-thread-5id) DEBUG ResourceLoaderHelper: 10 - Trying to upload data
2020-07-28 10:07:01 (pool-3-thread-5id) DEBUG ResourceLoaderHelper: 66 - Trying to upload data
2020-07-28 10:07:01 (pool-3-thread-5id) DEBUG ValidationXmlParser: 127 - No META-Only annotation
2020-07-28 14:48:00 (pool-2-thread-1id) DEBUG MessageWriter: 55 - Send message ErrorOutputMessage(super=NotificationOutputMessage(super=OutputMessage(type=null, messageId=116345, reqId=af24112))), error=ErrorOutputMessage.Error(code=400, text={
"errors": [
"Message type error"
]
})) to exchange FOS
2020-07-28 10:07:01 (pool-3-thread-5id) DEBUG ValidatorFactoryImpl: 578 - Scoped message interpolator.
I try to read that file in this way:
data <- readr::read_lines(file = "log_data.log", progress = FALSE)
log_df <- setDT(tibble::enframe(data, name = NULL))
But this dataframe looks like this:
value
1 2020-07-28 10:07:01 (pool-3-thread-5id) DEBUG ResourceLoaderHelper: 10 - Trying to upload data
2 2020-07-28 10:07:01 (pool-3-thread-5id) DEBUG ResourceLoaderHelper: 66 - Trying to upload data
3 2020-07-28 10:07:01 (pool-3-thread-5id) DEBUG ValidationXmlParser: 127 - No META-Only annotation
4 2020-07-28 14:48:00 (pool-2-thread-1id) DEBUG MessageWriter: 55 - Send message ErrorOutputMessage(super=NotificationOutputMessage(super=OutputMessage(type=null, messageId=116345, reqId=af24112))), error=ErrorOutputMessage.Error(code=400, text={
5 "errors": [
6 "Message type error"
7 ]
8 })) to exchange FOS
9 2020-07-28 10:07:01 (pool-3-thread-5id) DEBUG ValidatorFactoryImpl: 578 - Scoped message interpolator.
So as you see row number 4 splited into several rows, thought its one. How could i read this log file, so it understands that each row must start with timestamp? Should i use regular expressions somehow?