I'm looking for the best way to reliably archive the event logs from my OP2. i had posted a similar question back in December and lupinglade suggested using HH. i recently got a machine set up w/ HH for this purpose, but haven't got the event logging up and running.
my request for help in the other thread didn't a response and i couldn't figure out how to move it to the Haiku/Haikuhelper subforum where it would get more attention from those who can help, i'm posting again here (note to mods: it would be great if you could combine these two threads)
I tried writing the following script but it doesn't appear to properly retrieve the events. the fields are all 'undefined', even though if I go to http://localhost/api/controller.events i get back data that looks correct.
thanks!
my request for help in the other thread didn't a response and i couldn't figure out how to move it to the Haiku/Haikuhelper subforum where it would get more attention from those who can help, i'm posting again here (note to mods: it would be great if you could combine these two threads)
I tried writing the following script but it doesn't appear to properly retrieve the events. the fields are all 'undefined', even though if I go to http://localhost/api/controller.events i get back data that looks correct.
thanks!
Code:
var isCollectingEvents = false;
var lastCollectionTS = 0;
function onRefreshConfig(forced) {
controller.refreshEvents();
}
function onSyncStart(forced, timestamp) {
if(!isCollectingEvents) collectEvents();
}
function collectEvents() {
if(controller.isConnected) { // don't log nonsense if not connected
isCollectingEvents = true;
var line = '';
var count = 0;
var firstEventSeen = 0;
var lastEventSeen = 0;
var collectionTS = controller.date;
var events = controller.events;
for (var i in events) { // events are most-recent first
var e = events[i];
if (e.dateIsValid && e.date <= lastCollectionTS) {
break;
}
line+= e.dateDescription + ": " + e.eventDescription + "\n";
count++;
if (lastEventSeen == 0) {
lastEventSeen = e.date;
}
firstEventSeen = e.date;
}
lastCollectionTS = collectionTS;
helper.logToExternalFile('EventLog.txt', count + " events between ["
+ firstEventSeen + " - " + lastEventSeen + "] collected at "
+ lastCollectionTS);
helper.logToExternalFile('EventLog.txt', line);
helper.log(controller, count + " events between [" + firstEventSeen
+ " - " + lastEventSeen + "] collected at " + lastCollectionTS);
setTimeout('collectEvents()', 10*60*1000); // Every 10 minutes
}
else {
isCollectingEvents = false;
}
}