Previously:
Content could be returned like this, skipping a huge part of the file if the cache contained lines from vastly different parts of the file:
The lines at the end of the file sometimes looked like this
Or this
Or the end was not really the end
And there were a variating amount of empty lines after the loglines ended.
Now:
The last line should have no empty lines after it. When following tail the new lines appear at the bottom instead of over the empty lines, if they are there. And the returned lines does not contain different parts of the file.
I updated the searchCache with things I had previously removed, thinking we did not need it, but yes it turned out we did... I altered parts of that as well and added tests to check that it works.
The cache.js was starting to grow and the test file was getting messy. I split up the functions and added some into src/js/helpers/cacheHelper.js. All functions related to the cache should now have tests.
The frontend now sends a boolean in the getNewLogLines request, indicating wether it wants the end of the file or not and if true, the backend returns the current end of the file. This proved to be helpful when the file was running and the file size was constantly changing.
Other fixes:
Increased the number of lines in the frontend cache to be around 2000 (before, around 500) to lessen the amount of requests needed for new lines to the backend. The viewer does not jump as much as the number of updates are decreased.
Added a debounce to the getnewLogLines function in LogViewer to not trigger too many requests while dragging the scrollbar.
I tried to refactor as best as I could, though I feel that this is not the prettiest code I have written. At least it seems to work:) Please tell me if anything looks weird, or suggest changes. Over all I feel that the behavior has improved. Let me know what you think!
Previously: Content could be returned like this, skipping a huge part of the file if the cache contained lines from vastly different parts of the file:
The lines at the end of the file sometimes looked like this Or this Or the end was not really the end And there were a variating amount of empty lines after the loglines ended.
Now: The last line should have no empty lines after it. When following tail the new lines appear at the bottom instead of over the empty lines, if they are there. And the returned lines does not contain different parts of the file.
Other fixes:
I tried to refactor as best as I could, though I feel that this is not the prettiest code I have written. At least it seems to work:) Please tell me if anything looks weird, or suggest changes. Over all I feel that the behavior has improved. Let me know what you think!