Analogy-LogViewer / Analogy.LogViewer.RegexParser

Regular Expression Parser for simple text files
MIT License
1 stars 2 forks source link

Support logs with multiple lines #216

Open bdovaz opened 2 weeks ago

bdovaz commented 2 weeks ago

In our case, we have logs that either by our code or third parties, the reality is that they can generate multi-line logs.

For example, for a log to output a stacktrace:

2024-01-01 12:00:00,000 [1] DBG [TestClass] - A text
other text
other text2
2024-01-01 12:00:00,000 [1] DBG [TestClass] - A text 2
other text3
other text4

The problem comes that although my regex works in regex101.com, I see that the implementation makes it read the file line by line and execute the regex line by line instead of as a whole:

https://github.com/Analogy-LogViewer/Analogy.LogViewer.RegexParser/blob/d0b36774f5fb4b5e144bd55a63599421cf7d728d/Analogy.LogViewer.RegexParser/AnalogyRegexParser.cs#L271

This makes my regex not work obviously because it expects the input of the regex to be the content of the whole file and not line by line.

Would it be possible to support this different behavior when executing the regex? I know that the feedback is not the same because by not reading line by line you can't report progress (messagesHandler.ReportFileReadProgress()). But we are talking about that not all log files size is 100MB or more.

If so I could lend a hand with a PR if needed.

Thank you.

LiorBanai commented 2 weeks ago

Each data provider factory can have multiple different parser so this can be an addition to the existing one: https://github.com/Analogy-LogViewer/Analogy.LogViewer.RegexParser/blob/d0b36774f5fb4b5e144bd55a63599421cf7d728d/Analogy.LogViewer.RegexParser/IAnalogy/RegexDataProvidersFactory.cs#L14

we can can create new provider, something like RegexFullFileOfflineDataProvider. You can implement it in a pr if you wish or I will try to get to it next week.