{"size": 1078, "ext": "js", "max_stars_repo_path": "app/global/services/logger-svc.js", "max_stars_repo_name": "robotnoises/cherrytask", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app/global/services/logger-svc.js", "max_issues_repo_name": "robotnoises/cherrytask", "max_issues_repo_issues_event_min_datetime": "2015-06-10T15:36:04.000Z", "max_issues_repo_issues_event_max_datetime": "2015-06-10T15:36:04.000Z", "max_forks_repo_path": "app/global/services/logger-svc.js", "max_forks_repo_name": "robotnoises/cherrytask", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 22.4583333333, "max_line_length": 119, "alphanum_fraction": 0.5538033395}
/* global angular */

(function (angular) {

  'use strict';

  angular.module('cherry.global')

  .factory('logger', ['fbutil', 'apiService', function(fbutil, api) {
 	
    var pub = {};
    
    // Private
    
    var writeLog = function (log) {
      api.create('activity_log/', log).then(function (snap) {
      // console.log(snapshot.val());
      }).catch(function (err) {
        console.error(err);
      });
    };
    
    // Public
  
    var _info = function (message) {
      var log = { type: 'INFO', date_created: new Date().getTime(), message: message };
      writeLog(log);
    };
      
    var _warning = function (message) {
      var log = { type: 'WARNING', date_created: new Date().getTime(), message: message };
      writeLog(log);
    };
    
    var _error = function (exception) {
      var log = { type: 'ERROR', date_created: new Date().getTime(), message: exception.message || "Uncaught error." };
      writeLog(log);
    };
    
    pub.info = _info;
    pub.warning = _warning;
    pub.error = _error;
	
    return pub;
  }]);

})(angular);
