I am working on a logger for my application. I need to order my logs from the newest to the oldest. However, by default Winston saves my logs from top down (oldest on top, new log lines on last line). Finding a solution to get the lines saved in reverse is a one way to go. Another one is probably reading the files stream backwards using fs module. However, I am not able to find any precise answers for neither solution. Any help would be appreciated.
Asked
Active
Viewed 93 times
0
-
Writing logs from the newest to the oldest means rewriting all data in the log file on every log message rather than appending just one line to the file. That would be ineffective and very slow. So just read the log file and sort lines in memory, or you can write to some storage that gives access to log lines in any order (e.g. Seq) – Sergey Berezovskiy Jan 27 '23 at 12:15