I have the following code:
time = os.date("*t")
data = io.open("test.txt", "a")
function applicationWatcher(appName, eventType, appObject)
if (eventType == hs.application.watcher.launched) then
data:write("" .. appName .. " launched at ".. ("%02d:%02d:%02d:%02d:%02d:%02d"):format(time.day, time.month, time.year, time.hour, time.min, time.sec))
end
end
local appWatcher = hs.application.watcher.new(applicationWatcher)
appWatcher:start()
This code sees when you launch an application on macOS. I want the program to log the time, date and the application's name in a file so that I can see which apps I've launched, and when.
Nothing appears to get logged into my text file. Why?