|
Post by zipper on Jun 4, 2018 18:51:21 GMT
Im looking for a way to add text generated by script to the beginning of a log file. Googled and found a couple of examples that unfortunately don't work straight off in ankulua. I understand that one, perhaps only?, solution is to read the log file in to a table then create a new file and write the new log text to that file and then append the table containing the complete old log file and finally delete old textile and rename new file to old file name. I would appreciate if someone could help me out with this.
|
|
|
Post by AnkuLua on Jun 5, 2018 7:34:47 GMT
|
|
|
Post by zipper on Jun 7, 2018 17:15:45 GMT
I tried that already but the text appended from the table end up as one row after the first line line written to the file making a useless log file. If you have a idea how to get the table contents written line by line would be great.
|
|
|
Post by Acera Dryd on Jun 8, 2018 8:17:59 GMT
Why is it so necessary, that you append text at the beginning of the file? Is it only because the log file is to long to scroll down? If yes, then why dont you implement a method, that removes after 100 inserts the file log.txt.3, renames log.txt.2 to log.txt.3, log.txt.1 to log.txt.2 and log.txt to log.txt.1. After that you create a new log.txt and write to it until you reach again 100 inserts. Then you repeat the above method. This is like a rotation and some linux derivates use it
|
|
|
Post by zipper on Jun 21, 2018 11:09:20 GMT
I use the logfile to evaluate performance over time and periodical quick check that script behaved correctly. Log has 100s of entries per day and i connect remotely to the devices to share screen which means scrolling is a pain. Having the last entry on top would solve this very nicely.
|
|
ATG
Junior Member
Posts: 79
|
Post by ATG on Aug 5, 2020 12:09:25 GMT
I use the logfile to evaluate performance over time and periodical quick check that script behaved correctly. Log has 100s of entries per day and i connect remotely to the devices to share screen which means scrolling is a pain. Having the last entry on top would solve this very nicely. well this is old post and i got the solution. Future new readers may find this useful and want to do similar thing.
I'm using QuickLook, always wanted to read the first line by tap the space bar only without scrolling.
The link that was provided by Ankulua to the original post is actually the solution. you need to tweak one particular line of code for it to work.
-- ORIGINAL CODE for _, line in ipairs(lines) do out:write(line) end
--modify and add "\n", voila it will work for _, line in ipairs(lines) do out:write(line .. "\n") end
|
|