/*! * fileLogger * Copyright 2015 Peter Bakondy https://github.com/pbakondy * See LICENSE in this repository for license information */ !function(){angular.module("fileLogger",["ngCordova.plugins.file"]).factory("$fileLogger",["$q","$window","$cordovaFile","$timeout","$filter",function(e,o,n,r,t){"use strict";function a(){return!o.cordova&&!o.PhoneGap&&!o.phonegap}function l(e){angular.isString(e)?(e=e.toUpperCase(),-1===O.indexOf(e)&&(e="INFO")):e="INFO";for(var o,n=new Date,r=m?t("date")(n,m,F):n.toJSON(),l=Array.prototype.slice.call(arguments,1),c=[r,e],s=0;s0?(R=e,!0):!1}function g(e,o){if(!angular.isUndefined(e)&&!angular.isString(e))throw new TypeError("format parameter must be a string or undefined");if(!angular.isUndefined(o)&&!angular.isString(o))throw new TypeError("timezone parameter must be a string or undefined");m=e,F=o}function p(){var r=e.defer();return a()?r.resolve({name:R,localURL:"localStorage://localhost/"+R,type:"text/plain",size:o.localStorage[R]?o.localStorage[R].length:0}):n.checkFile(cordova.file.dataDirectory,R).then(function(e){e.file(r.resolve,r.reject)},r.reject),r.promise}function d(){var e=Array.prototype.slice.call(arguments,0);e.unshift("DEBUG"),l.apply(void 0,e)}function y(){var e=Array.prototype.slice.call(arguments,0);e.unshift("INFO"),l.apply(void 0,e)}function v(){var e=Array.prototype.slice.call(arguments,0);e.unshift("WARN"),l.apply(void 0,e)}function h(){var e=Array.prototype.slice.call(arguments,0);e.unshift("ERROR"),l.apply(void 0,e)}var m,F,S=[],b=!1,O=["DEBUG","INFO","WARN","ERROR"],R="messages.log";return{log:l,getLogfile:s,deleteLogfile:u,setStorageFilename:f,setTimestampFormat:g,checkFile:p,debug:d,info:y,warn:v,error:h}}])}();