Skip to content

Commit

Permalink
Improve logging. set status track item to null after sleep.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maigo Erit committed May 1, 2016
1 parent ca080d0 commit e119ab7
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app/background.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ var addInactivePeriod = function (beginDate, endDate) {
item.beginDate = beginDate;
item.endDate = endDate;
log.info("Adding inactive trackitem", item);
lastStatusTrackItemSaved = null;
createOrUpdateStatusItem(item);
}

Expand Down Expand Up @@ -150,16 +151,16 @@ var createOrUpdateAppItem = function (appTrackItem) {
var afterMidnight = dateToAfterMidnight(appTrackItem.beginDate);
var originalEndDate = appTrackItem.endDate;

log.debug('Midnight- almostMidnight: ' + almostMidnight + ', ' + afterMidnight);
log.debug('Midnight - almostMidnight: ' + almostMidnight + ', afterMidnight:' + afterMidnight);
appTrackItem.endDate = almostMidnight;
createOrUpdateAppItem(appTrackItem).then(function (item1) {
lastAppTrackItemSaved = null;
log.debug('Midnight- Saved one: ' + item1);
log.debug('Midnight - Saved one (before midnight): ' + item1);
item1.beginDate = afterMidnight;
item1.endDate = originalEndDate;
log.debug('Midnight- Saving second: ' + item1);
log.debug('Midnight - Saving second (after midnight): ' + item1);
createOrUpdateAppItem(getRawTrackItem(item1)).then(function (item2) {
log.debug('Midnight- Saved second: ' + item2);
log.debug('Midnight- Saved second (after midnight): ' + item2);
deferred.resolve(item2);
});
});
Expand Down Expand Up @@ -276,7 +277,7 @@ var saveActiveWindow = function (newAppTrackItem) {
return;
}
if (lastStatusTrackItemSaved !== null && lastStatusTrackItemSaved.app === 'IDLE') {
log.info('Not saving', lastStatusTrackItemSaved);
log.debug('Not saving, app is idling', newAppTrackItem);
//addRawTrackItemToList(emptyItem);
lastAppTrackItemSaved = null;
return
Expand Down Expand Up @@ -396,7 +397,7 @@ BackgroundService.saveForegroundWindowTitle = function () {
log.debug('Script saveForegroundWindowTitle file: ' + script);

exec(script, function (error, stdout, stderr) {
log.debug('saveForegroundWindowTitle: ' + stdout);
log.debug('Foreground window: ' + stdout);

if (stderr) {
log.debug('saveUserIdleTime error: ' + stderr);
Expand All @@ -421,7 +422,7 @@ BackgroundService.saveForegroundWindowTitle = function () {
active.beginDate = beginDate;
active.endDate = now;

log.debug("Active item:", active);
log.debug("Foreground window (parsed):", active);

saveActiveWindow(active);
});
Expand All @@ -442,7 +443,7 @@ BackgroundService.saveUserIdleTime = function () {
log.debug('Script saveUserIdleTime file: ' + script)

return exec(script, function (error, stdout, stderr) {
log.debug('saveUserIdleTime: ' + stdout);
log.debug('Idle time: ' + stdout);
if (stderr) {
log.debug('saveUserIdleTime error: ' + stderr);
}
Expand Down

0 comments on commit e119ab7

Please sign in to comment.