diff options
Diffstat (limited to 'www/lib/filelogger')
| -rw-r--r-- | www/lib/filelogger/.bower.json | 17 | ||||
| -rw-r--r-- | www/lib/filelogger/README.md | 14 | ||||
| -rw-r--r-- | www/lib/filelogger/bower.json | 6 | ||||
| -rw-r--r-- | www/lib/filelogger/dist/filelogger.js | 33 | ||||
| -rw-r--r-- | www/lib/filelogger/dist/filelogger.min.js | 4 | ||||
| -rw-r--r-- | www/lib/filelogger/package.json | 31 |
6 files changed, 70 insertions, 35 deletions
diff --git a/www/lib/filelogger/.bower.json b/www/lib/filelogger/.bower.json index ff9be55e..806271c7 100644 --- a/www/lib/filelogger/.bower.json +++ b/www/lib/filelogger/.bower.json @@ -1,11 +1,11 @@ { "name": "filelogger", - "version": "1.3.0", + "version": "1.3.1", "homepage": "https://github.com/pbakondy/filelogger", "authors": [ "Peter Bakondy <pbakondy@gmail.com>" ], - "description": "Cordova library to log messages to local filesystem", + "description": "Ionic library to log messages to local filesystem", "main": "./dist/filelogger.min.js", "ignore": [ "**/.*", @@ -14,7 +14,7 @@ "config" ], "dependencies": { - "ngCordova": ">= 0.1.14-alpha" + "ngCordova": ">= 0.1.24-alpha" }, "keywords": [ "cordova", @@ -27,14 +27,13 @@ "file logger" ], "license": "MIT", - "_release": "1.3.0", + "_release": "1.3.1", "_resolution": { "type": "version", - "tag": "v1.3.0", - "commit": "9500dca94558ffb27de6416c6031ddf54e183265" + "tag": "v1.3.1", + "commit": "420508b796674ca0f96da0bc04d80a627f9aebbe" }, - "_source": "git://github.com/pbakondy/filelogger.git", + "_source": "https://github.com/pbakondy/filelogger.git", "_target": "~1.3.0", - "_originalSource": "filelogger", - "_direct": true + "_originalSource": "filelogger" }
\ No newline at end of file diff --git a/www/lib/filelogger/README.md b/www/lib/filelogger/README.md index e0e29aa3..0fe3054d 100644 --- a/www/lib/filelogger/README.md +++ b/www/lib/filelogger/README.md @@ -1,9 +1,9 @@ -Cordova File Logger +Ionic File Logger ========== [](http://bower.io/search/?q=filelogger) -Logger module for Cordova/Ionic projects. +Logger module for Ionic projects. When you run your application in device the Logger writes in the local filesystem (with cordova-plugin-file) and the system logs (with console.log). @@ -11,7 +11,7 @@ When you run your application in browser with „ionic serve” the Logger uses ## Dependencies -- [ngCordova](http://ngcordova.com/) ( required version v0.1.14-alpha ) +- [ngCordova](http://ngcordova.com/) ( required version v0.1.24-alpha ) - [cordova-plugin-file](https://github.com/apache/cordova-plugin-file) ## Installation @@ -28,6 +28,12 @@ Install manually, or from bower: $ bower install filelogger ``` +Install with npm: + +```bash +$ npm install ionic-filelogger +``` + Include *filelogger.min.js* and ng-cordova.js or *ng-cordova.min.js* in your index.html file before cordova.js and after your AngularJS / Ionic file (since ngCordova depends on AngularJS). ```html @@ -181,4 +187,4 @@ angular.module('starter', ['ionic', 'fileLogger']) ## LICENSE -Cordova File Logger is licensed under the MIT Open Source license. For more information, see the LICENSE file in this repository. +Ionic File Logger is licensed under the MIT Open Source license. For more information, see the LICENSE file in this repository. diff --git a/www/lib/filelogger/bower.json b/www/lib/filelogger/bower.json index 3ec2e262..84f96637 100644 --- a/www/lib/filelogger/bower.json +++ b/www/lib/filelogger/bower.json @@ -1,11 +1,11 @@ { "name": "filelogger", - "version": "1.3.0", + "version": "1.3.1", "homepage": "https://github.com/pbakondy/filelogger", "authors": [ "Peter Bakondy <pbakondy@gmail.com>" ], - "description": "Cordova library to log messages to local filesystem", + "description": "Ionic library to log messages to local filesystem", "main": "./dist/filelogger.min.js", "ignore": [ "**/.*", @@ -14,7 +14,7 @@ "config" ], "dependencies": { - "ngCordova": ">= 0.1.14-alpha" + "ngCordova": ">= 0.1.24-alpha" }, "keywords": [ "cordova", diff --git a/www/lib/filelogger/dist/filelogger.js b/www/lib/filelogger/dist/filelogger.js index fa5f2625..8a90ab5c 100644 --- a/www/lib/filelogger/dist/filelogger.js +++ b/www/lib/filelogger/dist/filelogger.js @@ -1,10 +1,11 @@ /*! * fileLogger - * Copyright 2015 Peter Bakondy https://github.com/pbakondy + * Copyright 2016 Peter Bakondy https://github.com/pbakondy * See LICENSE in this repository for license information */ (function(){ /* global angular, console, cordova */ +/* eslint no-console:0 */ // install : cordova plugin add cordova-plugin-file // date format: https://docs.angularjs.org/api/ng/filter/date @@ -57,7 +58,9 @@ angular.module('fileLogger', ['ngCordova.plugins.file']) try { // avoid "TypeError: Converting circular structure to JSON" text = JSON.stringify(messages[i]); - } catch(e) {} + } catch(e) { + // do nothing + } message.push(text); } else if (angular.isObject(messages[i])) { @@ -65,7 +68,9 @@ angular.module('fileLogger', ['ngCordova.plugins.file']) try { // avoid "TypeError: Converting circular structure to JSON" text = JSON.stringify(messages[i]); - } catch(e) {} + } catch(e) { + // do nothing + } message.push(text); } else { @@ -167,6 +172,11 @@ angular.module('fileLogger', ['ngCordova.plugins.file']) } else { + if (!$window.cordova || !$window.cordova.file || !$window.cordova.file.dataDirectory) { + q.reject('cordova.file.dataDirectory is not available'); + return q.promise; + } + $cordovaFile.checkFile(cordova.file.dataDirectory, storageFilename).then( function() { // writeExistingFile(path, fileName, text) @@ -204,6 +214,12 @@ angular.module('fileLogger', ['ngCordova.plugins.file']) if (isBrowser()) { q.resolve($window.localStorage[storageFilename]); } else { + + if (!$window.cordova || !$window.cordova.file || !$window.cordova.file.dataDirectory) { + q.reject('cordova.file.dataDirectory is not available'); + return q.promise; + } + $cordovaFile.readAsText(cordova.file.dataDirectory, storageFilename).then( function(result) { q.resolve(result); @@ -225,6 +241,12 @@ angular.module('fileLogger', ['ngCordova.plugins.file']) $window.localStorage.removeItem(storageFilename); q.resolve(); } else { + + if (!$window.cordova || !$window.cordova.file || !$window.cordova.file.dataDirectory) { + q.reject('cordova.file.dataDirectory is not available'); + return q.promise; + } + $cordovaFile.removeFile(cordova.file.dataDirectory, storageFilename).then( function(result) { q.resolve(result); @@ -276,6 +298,11 @@ angular.module('fileLogger', ['ngCordova.plugins.file']) } else { + if (!$window.cordova || !$window.cordova.file || !$window.cordova.file.dataDirectory) { + q.reject('cordova.file.dataDirectory is not available'); + return q.promise; + } + $cordovaFile.checkFile(cordova.file.dataDirectory, storageFilename).then(function(fileEntry) { fileEntry.file(q.resolve, q.reject); }, q.reject); diff --git a/www/lib/filelogger/dist/filelogger.min.js b/www/lib/filelogger/dist/filelogger.min.js index 4fd8ec79..de02b863 100644 --- a/www/lib/filelogger/dist/filelogger.min.js +++ b/www/lib/filelogger/dist/filelogger.min.js @@ -1,6 +1,6 @@ /*! * fileLogger - * Copyright 2015 Peter Bakondy https://github.com/pbakondy + * Copyright 2016 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;s<l.length;s++)if(angular.isArray(l[s])){o="[Array]";try{o=JSON.stringify(l[s])}catch(u){}c.push(o)}else if(angular.isObject(l[s])){o="[Object]";try{o=JSON.stringify(l[s])}catch(u){}c.push(o)}else c.push(l[s]);if(a()){if(l.unshift(r),angular.isObject(console)&&angular.isFunction(console.log))switch(e){case"DEBUG":angular.isFunction(console.debug)?console.debug.apply(console,l):console.log.apply(console,l);break;case"INFO":angular.isFunction(console.debug)?console.info.apply(console,l):console.log.apply(console,l);break;case"WARN":angular.isFunction(console.debug)?console.warn.apply(console,l):console.log.apply(console,l);break;case"ERROR":angular.isFunction(console.debug)?console.error.apply(console,l):console.log.apply(console,l);break;default:console.log.apply(console,l)}}else console.log(c.join(" "));S.push({message:c.join(" ")+"\n"}),b||i()}function i(){if(!S.length)return void(b=!1);b=!0;var e=S.shift();c(e.message).then(function(){r(function(){i()})},function(){r(function(){i()})})}function c(r){var t=e.defer();return a()?(o.localStorage[R]||(o.localStorage[R]=""),o.localStorage[R]+=r,t.resolve()):n.checkFile(cordova.file.dataDirectory,R).then(function(){n.writeExistingFile(cordova.file.dataDirectory,R,r).then(function(){t.resolve()},function(e){t.reject(e)})},function(){n.writeFile(cordova.file.dataDirectory,R,r,!0).then(function(){t.resolve()},function(e){t.reject(e)})}),t.promise}function s(){var r=e.defer();return a()?r.resolve(o.localStorage[R]):n.readAsText(cordova.file.dataDirectory,R).then(function(e){r.resolve(e)},function(e){r.reject(e)}),r.promise}function u(){var r=e.defer();return a()?(o.localStorage.removeItem(R),r.resolve()):n.removeFile(cordova.file.dataDirectory,R).then(function(e){r.resolve(e)},function(e){r.reject(e)}),r.promise}function f(e){return angular.isString(e)&&e.length>0?(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}}])}();
\ No newline at end of file +!function(){angular.module("fileLogger",["ngCordova.plugins.file"]).factory("$fileLogger",["$q","$window","$cordovaFile","$timeout","$filter",function(e,o,r,a,n){"use strict";function t(){return!o.cordova&&!o.PhoneGap&&!o.phonegap}function i(e){angular.isString(e)?(e=e.toUpperCase(),-1===S.indexOf(e)&&(e="INFO")):e="INFO";for(var o,r=new Date,a=m?n("date")(r,m,b):r.toJSON(),i=Array.prototype.slice.call(arguments,1),c=[a,e],s=0;s<i.length;s++)if(angular.isArray(i[s])){o="[Array]";try{o=JSON.stringify(i[s])}catch(f){}c.push(o)}else if(angular.isObject(i[s])){o="[Object]";try{o=JSON.stringify(i[s])}catch(f){}c.push(o)}else c.push(i[s]);if(t()){if(i.unshift(a),angular.isObject(console)&&angular.isFunction(console.log))switch(e){case"DEBUG":angular.isFunction(console.debug)?console.debug.apply(console,i):console.log.apply(console,i);break;case"INFO":angular.isFunction(console.debug)?console.info.apply(console,i):console.log.apply(console,i);break;case"WARN":angular.isFunction(console.debug)?console.warn.apply(console,i):console.log.apply(console,i);break;case"ERROR":angular.isFunction(console.debug)?console.error.apply(console,i):console.log.apply(console,i);break;default:console.log.apply(console,i)}}else console.log(c.join(" "));F.push({message:c.join(" ")+"\n"}),D||l()}function l(){if(!F.length)return void(D=!1);D=!0;var e=F.shift();c(e.message).then(function(){a(function(){l()})},function(){a(function(){l()})})}function c(a){var n=e.defer();if(t())o.localStorage[j]||(o.localStorage[j]=""),o.localStorage[j]+=a,n.resolve();else{if(!o.cordova||!o.cordova.file||!o.cordova.file.dataDirectory)return n.reject("cordova.file.dataDirectory is not available"),n.promise;r.checkFile(cordova.file.dataDirectory,j).then(function(){r.writeExistingFile(cordova.file.dataDirectory,j,a).then(function(){n.resolve()},function(e){n.reject(e)})},function(){r.writeFile(cordova.file.dataDirectory,j,a,!0).then(function(){n.resolve()},function(e){n.reject(e)})})}return n.promise}function s(){var a=e.defer();if(t())a.resolve(o.localStorage[j]);else{if(!o.cordova||!o.cordova.file||!o.cordova.file.dataDirectory)return a.reject("cordova.file.dataDirectory is not available"),a.promise;r.readAsText(cordova.file.dataDirectory,j).then(function(e){a.resolve(e)},function(e){a.reject(e)})}return a.promise}function f(){var a=e.defer();if(t())o.localStorage.removeItem(j),a.resolve();else{if(!o.cordova||!o.cordova.file||!o.cordova.file.dataDirectory)return a.reject("cordova.file.dataDirectory is not available"),a.promise;r.removeFile(cordova.file.dataDirectory,j).then(function(e){a.resolve(e)},function(e){a.reject(e)})}return a.promise}function u(e){return angular.isString(e)&&e.length>0?(j=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,b=o}function d(){var a=e.defer();if(t())a.resolve({name:j,localURL:"localStorage://localhost/"+j,type:"text/plain",size:o.localStorage[j]?o.localStorage[j].length:0});else{if(!o.cordova||!o.cordova.file||!o.cordova.file.dataDirectory)return a.reject("cordova.file.dataDirectory is not available"),a.promise;r.checkFile(cordova.file.dataDirectory,j).then(function(e){e.file(a.resolve,a.reject)},a.reject)}return a.promise}function p(){var e=Array.prototype.slice.call(arguments,0);e.unshift("DEBUG"),i.apply(void 0,e)}function v(){var e=Array.prototype.slice.call(arguments,0);e.unshift("INFO"),i.apply(void 0,e)}function y(){var e=Array.prototype.slice.call(arguments,0);e.unshift("WARN"),i.apply(void 0,e)}function h(){var e=Array.prototype.slice.call(arguments,0);e.unshift("ERROR"),i.apply(void 0,e)}var m,b,F=[],D=!1,S=["DEBUG","INFO","WARN","ERROR"],j="messages.log";return{log:i,getLogfile:s,deleteLogfile:f,setStorageFilename:u,setTimestampFormat:g,checkFile:d,debug:p,info:v,warn:y,error:h}}])}();
\ No newline at end of file diff --git a/www/lib/filelogger/package.json b/www/lib/filelogger/package.json index a3cc3938..27dac364 100644 --- a/www/lib/filelogger/package.json +++ b/www/lib/filelogger/package.json @@ -1,26 +1,29 @@ { - "name": "filelogger", + "name": "ionic-filelogger", "private": false, "main": "dist/filelogger", - "version": "1.3.0", + "version": "1.3.1", "repository": { - "url": "git://github.com/pbakondy/filelogger.git" + "type": "git", + "url": "https://github.com/pbakondy/filelogger.git" }, "devDependencies": { - "gulp": "^3.7.0", + "gulp": "^3.9.1", "gulp-footer": "^1.0.4", "gulp-header": "^1.0.2", - "gulp-jshint": "^1.6.1", + "gulp-jshint": "^2.0.0", "gulp-rename": "^1.2.0", - "gulp-uglify": "^0.2.1", - "jshint-stylish": "^0.4.0", - "minimist": "^0.1.0" + "gulp-uglify": "^1.5.3", + "jshint": "^2.8.0", + "jshint-stylish": "^2.1.0", + "minimist": "^1.2.0" }, - "licenses": [ - { - "type": "MIT" - } - ], + "license": "MIT", "dependencies": { - } + "ng-cordova": "^0.1.24-alpha" + }, + "bugs": { + "url": "https://github.com/pbakondy/filelogger/issues" + }, + "homepage": "https://github.com/pbakondy/filelogger#readme" } |
