Skip to content

Instantly share code, notes, and snippets.

@adamcarr
Created December 9, 2013 16:51
Show Gist options
  • Save adamcarr/7875676 to your computer and use it in GitHub Desktop.
Save adamcarr/7875676 to your computer and use it in GitHub Desktop.
Activity Logging Example
var initializeActivity = loggerService.startActivity(activities.testController.INITIALIZE);
$scope.currentDateTime = new Date();
loggerService.log('Setting $scope.currentDateTime to the current time: [' + $scope.currentDateTime + ']');
loggerService.endActivity(activities.testController.INITIALIZE);
$timeout(function () {
loggerService.log('logging something while in a timeout which should be outside initialize scope');
});
$timeout(function () {
loggerService.appendToActivity(initializeActivity, activities.testController.TIMEOUT);
loggerService.log('appending to the initialize activity');
$timeout(function () {
loggerService.log('logging something while in a timeout which should be outside initialize scope');
});
loggerService.endActivity(activities.testController.TIMEOUT);
}, 2000);
$scope.getTasks = function () {
loggerService.startActivity(activities.testController.GET_TASKS_WRAPPER);
var getTasksAction = loggerService.startActivity(activities.testController.GET_TASKS);
loggerService.log('Getting tasks');
$http.get('/tasks')
.success(function (tasks) {
loggerService.appendToActivity(getTasksAction, activities.testController.GET_TASKS_COMPLETE);
loggerService.log('tasks returned successfully', tasks);
$scope.tasks = tasks;
loggerService.endActivity(activities.testController.GET_TASKS_COMPLETE);
})
.error(function (error) {
loggerService.appendToActivity(getTasksAction, activities.testController.GET_TASKS_COMPLETE);
loggerService.log('tasks failed', error);
loggerService.endActivity(activities.testController.GET_TASKS_COMPLETE);
});
loggerService.endActivity(activities.testController.GET_TASKS);
loggerService.endActivity(activities.testController.GET_TASKS_WRAPPER);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment