diff options
Diffstat (limited to 'www/lib/filelogger')
| -rw-r--r-- | www/lib/filelogger/.bower.json | 39 | ||||
| -rw-r--r-- | www/lib/filelogger/LICENSE | 21 | ||||
| -rw-r--r-- | www/lib/filelogger/README.md | 190 | ||||
| -rw-r--r-- | www/lib/filelogger/bower.json | 30 | ||||
| -rw-r--r-- | www/lib/filelogger/dist/filelogger.js | 358 | ||||
| -rw-r--r-- | www/lib/filelogger/dist/filelogger.min.js | 6 | ||||
| -rw-r--r-- | www/lib/filelogger/package.json | 29 |
7 files changed, 0 insertions, 673 deletions
diff --git a/www/lib/filelogger/.bower.json b/www/lib/filelogger/.bower.json deleted file mode 100644 index 806271c7..00000000 --- a/www/lib/filelogger/.bower.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "filelogger", - "version": "1.3.1", - "homepage": "https://github.com/pbakondy/filelogger", - "authors": [ - "Peter Bakondy <pbakondy@gmail.com>" - ], - "description": "Ionic library to log messages to local filesystem", - "main": "./dist/filelogger.min.js", - "ignore": [ - "**/.*", - "gulpfile.js", - "src", - "config" - ], - "dependencies": { - "ngCordova": ">= 0.1.24-alpha" - }, - "keywords": [ - "cordova", - "cordova plugin", - "ionic", - "ionic plugin", - "angular module", - "log", - "logger", - "file logger" - ], - "license": "MIT", - "_release": "1.3.1", - "_resolution": { - "type": "version", - "tag": "v1.3.1", - "commit": "420508b796674ca0f96da0bc04d80a627f9aebbe" - }, - "_source": "https://github.com/pbakondy/filelogger.git", - "_target": "~1.3.0", - "_originalSource": "filelogger" -}
\ No newline at end of file diff --git a/www/lib/filelogger/LICENSE b/www/lib/filelogger/LICENSE deleted file mode 100644 index ec5a3987..00000000 --- a/www/lib/filelogger/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Peter Bakondy - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE.
\ No newline at end of file diff --git a/www/lib/filelogger/README.md b/www/lib/filelogger/README.md deleted file mode 100644 index 0fe3054d..00000000 --- a/www/lib/filelogger/README.md +++ /dev/null @@ -1,190 +0,0 @@ -Ionic File Logger -========== - -[](http://bower.io/search/?q=filelogger) - -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). - -When you run your application in browser with „ionic serve” the Logger uses browsers localStorage and the browser console (with console.log). - -## Dependencies - -- [ngCordova](http://ngcordova.com/) ( required version v0.1.24-alpha ) -- [cordova-plugin-file](https://github.com/apache/cordova-plugin-file) - -## Installation - -Add cordova plugin: - -```bash -$ cordova plugin add cordova-plugin-file -``` - -Install manually, or from bower: - -```bash -$ 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 -<script src="lib/ngCordova/dist/ng-cordova.min.js"></script> -<script src="lib/filelogger/dist/filelogger.min.js"></script> -<script src="cordova.js"></script> -``` - -Comment: you don't have to use the complete ngCordova package. I suggest to create a [Custom Build](http://ngcordova.com/build/) with file module. - - -## Usage - -### $fileLogger.log(level, ...message) - -General logger method. The first parameter is the log level (debug, info, warn, error). The following parameters are the message parts. -You can put here any javascript type (string, number, boolean, object, array). - -In the logfile every item starts with the current UTC timestamp, followed by the log level and the message. - -### $fileLogger.debug(...message) - -Wrapper for $fileLogger.log('debug', ...) - -### $fileLogger.info(...message) - -Wrapper for $fileLogger.log('info', ...) - -### $fileLogger.warn(...message) - -Wrapper for $fileLogger.log('warn', ...) - -### $fileLogger.error(...message) - -Wrapper for $fileLogger.log('error', ...) - -### $fileLogger.setStorageFilename(filename) - -You can set the local filename (default messages.log). It requests one parameter, the filename (type string). - -### $fileLogger.setTimestampFormat(format, timezone) - -You can customize the timestamp format using [Angular <code>date</code> filter](https://docs.angularjs.org/api/ng/filter/date). See formatting parameters on the linked Angular docs page. Example: - -```js -$fileLogger.setTimestampFormat('medium'); -``` - -### $fileLogger.getLogfile() - -You can read the whole logfile from the filestore. This method returns a promise. - -### $fileLogger.deleteLogfile() - -You can delete the logfile from the filestore. This method returns a promise. - -### $fileLogger.checkFile() - -Get storage file data. This method returns an object. - -```js -// response on iOS -{ - "name": "myLog.txt", - "localURL": "cdvfile://localhost/library-nosync/myLog.txt", - "type": null, - "lastModified": 1435668606000, - "lastModifiedDate": 1435668606000, - "size": 450, - "start": 0, - "end": 450 -} - -// response on Android -{ - "name": "myLog.txt", - "localURL": "cdvfile://localhost/files/myLog.txt", - "type": "text/plain", - "lastModified": 1435669292000, - "lastModifiedDate": 1435669292000, - "size": 450, - "start": 0, - "end": 450 -} - -// response in Browser -{ - "name": "myLog.txt", - "localURL": "localStorage://localhost/myLog.txt", - "type": "text/plain", - "size": 450 -} -``` - -### Example use - -```js -angular.module('starter', ['ionic', 'fileLogger']) - .controller('mainCtrl', ['$scope', '$fileLogger', '$timeout', function($scope, $fileLogger, $timeout) { - - function testing() { - - $fileLogger.setStorageFilename('myLog.txt'); - - $fileLogger.log('debug', 'message'); - $fileLogger.log('info', 'message'); - $fileLogger.log('warn', 'message'); - $fileLogger.log('error', 'message'); - - $fileLogger.debug('message'); - $fileLogger.info('message'); - $fileLogger.warn('message'); - $fileLogger.error('message'); - - $fileLogger.log('error', 'error message', { code: 1, meaning: 'general' }); - - $fileLogger.log('info', 'message', 123, [1, 2, 3], { a: 1, b: '2' }); - - $timeout(function(){ - $fileLogger.getLogfile().then(function(l) { - console.log('Logfile content'); - console.log(l); - }); - }, 1000); - - $timeout(function(){ - $fileLogger.checkFile().then(function(d) { - console.log('Logfile data'); - console.log(JSON.stringify(d)); - }); - }, 2000); - - $timeout(function(){ - $fileLogger.deleteLogfile().then(function() { - console.log('Logfile deleted'); - }); - }, 3000); - - } - -}]); -``` - - -## Author - -#### Peter Bakondy - -- https://github.com/pbakondy - - -## LICENSE - -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 deleted file mode 100644 index 84f96637..00000000 --- a/www/lib/filelogger/bower.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "filelogger", - "version": "1.3.1", - "homepage": "https://github.com/pbakondy/filelogger", - "authors": [ - "Peter Bakondy <pbakondy@gmail.com>" - ], - "description": "Ionic library to log messages to local filesystem", - "main": "./dist/filelogger.min.js", - "ignore": [ - "**/.*", - "gulpfile.js", - "src", - "config" - ], - "dependencies": { - "ngCordova": ">= 0.1.24-alpha" - }, - "keywords": [ - "cordova", - "cordova plugin", - "ionic", - "ionic plugin", - "angular module", - "log", - "logger", - "file logger" - ], - "license": "MIT" -} diff --git a/www/lib/filelogger/dist/filelogger.js b/www/lib/filelogger/dist/filelogger.js deleted file mode 100644 index 8a90ab5c..00000000 --- a/www/lib/filelogger/dist/filelogger.js +++ /dev/null @@ -1,358 +0,0 @@ -/*! - * fileLogger - * 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 - -angular.module('fileLogger', ['ngCordova.plugins.file']) - - .factory('$fileLogger', ['$q', '$window', '$cordovaFile', '$timeout', '$filter', - function ($q, $window, $cordovaFile, $timeout, $filter) { - - 'use strict'; - - - var queue = []; - var ongoing = false; - var levels = ['DEBUG', 'INFO', 'WARN', 'ERROR']; - - var storageFilename = 'messages.log'; - - var dateFormat; - var dateTimezone; - - - function isBrowser() { - return (!$window.cordova && !$window.PhoneGap && !$window.phonegap); - } - - - function log(level) { - if (angular.isString(level)) { - level = level.toUpperCase(); - - if (levels.indexOf(level) === -1) { - level = 'INFO'; - } - } else { - level = 'INFO'; - } - - var now = new Date(); - var timestamp = dateFormat ? - $filter('date')(now, dateFormat, dateTimezone) : now.toJSON(); - - var messages = Array.prototype.slice.call(arguments, 1); - var message = [ timestamp, level ]; - var text; - - for (var i = 0; i < messages.length; i++ ) { - if (angular.isArray(messages[i])) { - text = '[Array]'; - try { - // avoid "TypeError: Converting circular structure to JSON" - text = JSON.stringify(messages[i]); - } catch(e) { - // do nothing - } - message.push(text); - } - else if (angular.isObject(messages[i])) { - text = '[Object]'; - try { - // avoid "TypeError: Converting circular structure to JSON" - text = JSON.stringify(messages[i]); - } catch(e) { - // do nothing - } - message.push(text); - } - else { - message.push(messages[i]); - } - } - - if (isBrowser()) { - // log to browser console - - messages.unshift(timestamp); - - if (angular.isObject(console) && angular.isFunction(console.log)) { - switch (level) { - case 'DEBUG': - if (angular.isFunction(console.debug)) { - console.debug.apply(console, messages); - } else { - console.log.apply(console, messages); - } - break; - case 'INFO': - if (angular.isFunction(console.debug)) { - console.info.apply(console, messages); - } else { - console.log.apply(console, messages); - } - break; - case 'WARN': - if (angular.isFunction(console.debug)) { - console.warn.apply(console, messages); - } else { - console.log.apply(console, messages); - } - break; - case 'ERROR': - if (angular.isFunction(console.debug)) { - console.error.apply(console, messages); - } else { - console.log.apply(console, messages); - } - break; - default: - console.log.apply(console, messages); - } - } - - } else { - // log to logcat - console.log(message.join(' ')); - } - - queue.push({ message: message.join(' ') + '\n' }); - - if (!ongoing) { - process(); - } - } - - - function process() { - - if (!queue.length) { - ongoing = false; - return; - } - - ongoing = true; - var m = queue.shift(); - - writeLog(m.message).then( - function() { - $timeout(function() { - process(); - }); - }, - function() { - $timeout(function() { - process(); - }); - } - ); - - } - - - function writeLog(message) { - var q = $q.defer(); - - if (isBrowser()) { - // running in browser with 'ionic serve' - - if (!$window.localStorage[storageFilename]) { - $window.localStorage[storageFilename] = ''; - } - - $window.localStorage[storageFilename] += message; - 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.checkFile(cordova.file.dataDirectory, storageFilename).then( - function() { - // writeExistingFile(path, fileName, text) - $cordovaFile.writeExistingFile(cordova.file.dataDirectory, storageFilename, message).then( - function() { - q.resolve(); - }, - function(error) { - q.reject(error); - } - ); - }, - function() { - // writeFile(path, fileName, text, replaceBool) - $cordovaFile.writeFile(cordova.file.dataDirectory, storageFilename, message, true).then( - function() { - q.resolve(); - }, - function(error) { - q.reject(error); - } - ); - } - ); - - } - - return q.promise; - } - - - function getLogfile() { - var q = $q.defer(); - - 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); - }, - function(error) { - q.reject(error); - } - ); - } - - return q.promise; - } - - - function deleteLogfile() { - var q = $q.defer(); - - if (isBrowser()) { - $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); - }, - function(error) { - q.reject(error); - } - ); - } - - return q.promise; - } - - - function setStorageFilename(filename) { - if (angular.isString(filename) && filename.length > 0) { - storageFilename = filename; - return true; - } else { - return false; - } - } - - - function setTimestampFormat(format, timezone) { - if (!(angular.isUndefined(format) || angular.isString(format))) { - throw new TypeError('format parameter must be a string or undefined'); - } - if (!(angular.isUndefined(timezone) || angular.isString(timezone))) { - throw new TypeError('timezone parameter must be a string or undefined'); - } - - dateFormat = format; - dateTimezone = timezone; - } - - - function checkFile() { - var q = $q.defer(); - - if (isBrowser()) { - - q.resolve({ - 'name': storageFilename, - 'localURL': 'localStorage://localhost/' + storageFilename, - 'type': 'text/plain', - 'size': ($window.localStorage[storageFilename] ? $window.localStorage[storageFilename].length : 0) - }); - - } 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); - - } - - return q.promise; - } - - function debug() { - var args = Array.prototype.slice.call(arguments, 0); - args.unshift('DEBUG'); - log.apply(undefined, args); - } - - - function info() { - var args = Array.prototype.slice.call(arguments, 0); - args.unshift('INFO'); - log.apply(undefined, args); - } - - - function warn() { - var args = Array.prototype.slice.call(arguments, 0); - args.unshift('WARN'); - log.apply(undefined, args); - } - - - function error() { - var args = Array.prototype.slice.call(arguments, 0); - args.unshift('ERROR'); - log.apply(undefined, args); - } - - - return { - log: log, - getLogfile: getLogfile, - deleteLogfile: deleteLogfile, - setStorageFilename: setStorageFilename, - setTimestampFormat: setTimestampFormat, - checkFile: checkFile, - debug: debug, - info: info, - warn: warn, - error: error - }; - - }]); - -})();
\ No newline at end of file diff --git a/www/lib/filelogger/dist/filelogger.min.js b/www/lib/filelogger/dist/filelogger.min.js deleted file mode 100644 index de02b863..00000000 --- a/www/lib/filelogger/dist/filelogger.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - * fileLogger - * 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,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 deleted file mode 100644 index 27dac364..00000000 --- a/www/lib/filelogger/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "ionic-filelogger", - "private": false, - "main": "dist/filelogger", - "version": "1.3.1", - "repository": { - "type": "git", - "url": "https://github.com/pbakondy/filelogger.git" - }, - "devDependencies": { - "gulp": "^3.9.1", - "gulp-footer": "^1.0.4", - "gulp-header": "^1.0.2", - "gulp-jshint": "^2.0.0", - "gulp-rename": "^1.2.0", - "gulp-uglify": "^1.5.3", - "jshint": "^2.8.0", - "jshint-stylish": "^2.1.0", - "minimist": "^1.2.0" - }, - "license": "MIT", - "dependencies": { - "ng-cordova": "^0.1.24-alpha" - }, - "bugs": { - "url": "https://github.com/pbakondy/filelogger/issues" - }, - "homepage": "https://github.com/pbakondy/filelogger#readme" -} |
