I have specific log messages and I would like to parse it into groups. I would like to make an alternative version in case if my string is more specific.
My logs:
18:48:24:284 => [DEBUG] [xxx.yyy.zzz] [8] Message1
18:48:24:671 => [INFO] [uuu.www.aaa] [8] Method: 'ReturnType MethodName(MethodParameter)'. Line: ~30. Message2
I have written the following regex:
(?<timestamp>\d+:\d+:\d+:\d+.*)\s+=>\s+\[(?<level>\w+)\]\s+\[(?<emmiter>.*)\]\s+\[(?<thread>\d+)\]\s+(?<message>.*)
It parses these messages into specific groups:
timestamp: 18:48:24:284
level: DEBUG
emmiter: xxx.yyy.zzz
thread: 8
message: Message1
timestamp: 18:48:24:671
level: INFO
emmiter: uuu.www.aaa
thread: 8
message: Method: 'ReturnType MethodName(MethodParameter)'. Line: ~30. Message2
But right now I would like to add 2 more groups, in case if they exist: method and Line
So, I would like to get results like this:
timestamp: 18:48:24:284
level: DEBUG
emmiter: xxx.yyy.zzz
thread: 8
method:
line:
message: Message1
timestamp: 18:48:24:671
level: INFO
emmiter: uuu.www.aaa
thread: 8
method: ReturnType MethodName(MethodParameter)
line: ~30
message: Message2
Can you please help me with that? Everything I do results in parsing only Line1 or only Line2 properly, but I would like to parse them both with one regex.