diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a733be..7c611c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [unreleased] +## [0.1.0] - 2017-08-02 ### Added - Now constructor return `this` - Prefix options diff --git a/dist/katch.js b/dist/katch.js index 06daa99..37342f8 100644 --- a/dist/katch.js +++ b/dist/katch.js @@ -392,6 +392,10 @@ var Log = __webpack_require__(7); var Events = __webpack_require__(2); var sha256 = __webpack_require__(8); +/** + * Default options + * @type {{logging: boolean, writeFile: {prefix: string, humanize: boolean, folderPath: string}}} + */ var defaultConfig = { logging: true, writeFile: { @@ -403,6 +407,7 @@ var defaultConfig = { /** * katch + * @constructor * @see https://blog.sentry.io/2016/01/04/client-javascript-reporting-window-onerror.html * @param opts {object} options object */ @@ -412,7 +417,7 @@ function katch(opts) { if (Helpers.isBrowser()) { window.onerror = function (msg, url, lineNo, columnNo, error) { - katch.captureError(error, { + katch.error(error, { message: msg, url: url, lineNo: lineNo, @@ -420,7 +425,7 @@ function katch(opts) { }); }; } else { - process.on('uncaughtException', katch.captureError); + process.on('uncaughtException', katch.error); } return katch; @@ -434,7 +439,7 @@ katch.config = defaultConfig; /** * Set config - * @param opts + * @param opts {Object} configuration options */ katch.setup = function (opts) { if ((typeof opts === 'undefined' ? 'undefined' : _typeof(opts)) === 'object') { @@ -444,11 +449,10 @@ katch.setup = function (opts) { /** * Catch error - * @alias error * @param error {Error} error object * @param params {Object} optional params object */ -katch.captureError = function (error) { +katch.error = function (error) { var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var logObj = { @@ -466,11 +470,10 @@ katch.captureError = function (error) { /** * Catch error - * @alias captureError * @param error {Error} error object * @param params {Object} optional params object */ -katch.error = katch.captureError; +katch.captureError = katch.error; /** * Log info @@ -509,7 +512,7 @@ katch.wrap = function (func) { /** * Call events - * @param event {string} event name + * @param event {String} event name * @param callback {function} callback function */ katch.on = Events.on; diff --git a/dist/katch.min.js b/dist/katch.min.js index a01575b..f7f8b0d 100644 --- a/dist/katch.min.js +++ b/dist/katch.min.js @@ -1,2 +1,2 @@ // [AIV] katch Build version: 0.0.26 - var katch=function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=4)}([function(t,e,r){"use strict";function n(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function i(t){if(l===setTimeout)return setTimeout(t,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(t,0);try{return l(t,0)}catch(e){try{return l.call(null,t,0)}catch(e){return l.call(this,t,0)}}}function a(t){if(y===clearTimeout)return clearTimeout(t);if((y===o||!y)&&clearTimeout)return y=clearTimeout,clearTimeout(t);try{return y(t)}catch(e){try{return y.call(null,t)}catch(e){return y.call(this,t)}}}function u(){p&&m&&(p=!1,m.length?h=m.concat(h):g=-1,h.length&&c())}function c(){if(!p){var t=i(u);p=!0;for(var e=h.length;e;){for(m=h,h=[];++g1)for(var r=1;r0&&void 0!==arguments[0]?arguments[0]:"all",e=new Date;return"date"===t?o(e,"yyyy-mm-dd"):"time"===t?o(e,"HH:MM:ss"):o(e,"yyyy-mm-dd HH:MM:ss")},i.isServer=function(){return void 0!==e},i.isBrowser=function(){return"undefined"!=typeof window},t.exports=i}).call(e,r(0))},function(t,e,r){"use strict";var n={};n.events=[],n.on=function(t,e){n.events.push(t,e)},n.fire=function(){for(var t=arguments.length,e=Array(t),r=0;r1&&void 0!==arguments[1]?arguments[1]:{},r={time:i.getLocaleISODate(),type:"ERROR",hash:c(t.stack),message:t.stack,params:e};u.fire("error",t,e),u.fire("type"+t.name,t,e),a.write(r,n.config)},n.error=n.captureError,n.info=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={time:i.getLocaleISODate(),type:"INFO",hash:c(t),message:t,params:e,objectType:null};u.fire("info",t,e),a.write(r,n.config)},n.wrap=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{t()}catch(t){n.captureError(t,e)}},n.on=u.on,t.exports=n}).call(e,r(0))},function(t,e,r){"use strict";var n,o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(i){function a(t,e){for(t=String(t),e=e||2;t.length0?"-":"+")+a(100*Math.floor(Math.abs(b)/60)+Math.abs(b)%60,4),S:["th","st","nd","rd"][m%10>3?0:(m%100-m%10!=10)*m%10],W:w,N:D};return o.replace(t,function(t){return t in C?C[t]:t.slice(1,t.length-1)})}}();f.masks={default:"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:sso",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'",expiresHeaderFormat:"ddd, dd mmm yyyy HH:MM:ss Z"},f.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]},void 0!==(n=function(){return f}.call(e,r,e,t))&&(t.exports=n)}()},function(t,e,r){"use strict";(function(e){var n=r(1),o=r(2),i=r(3),a=r(3),u={};u.write=function(t,r){if(n.isBrowser()){if(t.useragent=navigator.userAgent,r.logging){var u=n.getLocaleISODate("date"),c=JSON.parse(localStorage.getItem("katch"))||{};c[u]||(c[u]=[]),c[u].push(t);try{localStorage.setItem("katch",JSON.stringify(c))}catch(t){localStorage.clear(),localStorage.setItem("katch",JSON.stringify(c))}}}else{var s=n.getLocaleISODate("date")+".log",f=r.writeFile.folderPath,l="",y=r.writeFile.prefix;if(t.host=a.hostname(),t.pid=e.pid,t.platform=e.platform,r.logging){if(r.writeFile.humanize){l="["+t.time+"] ["+t.type+"] ["+t.host+"] ["+t.hash+"] \n"+t.message+"\n------------------------------------------------------------------------------------\n"}else l=JSON.stringify(t)+"\n";r.writeFile&&(i.existsSync(f)||i.mkdirSync(f),i.appendFileSync(f+"/"+y+s,l))}}o.fire("log",t)},t.exports=u}).call(e,r(0))},function(t,e,r){"use strict";function n(t){function e(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function r(t,e){return t>>>e|t<<32-e}function n(t,e){return t>>>e}function o(t,e,r){return t&e^~t&r}function i(t,e,r){return t&e^t&r^e&r}function a(t){return r(t,2)^r(t,13)^r(t,22)}function u(t){return r(t,6)^r(t,11)^r(t,25)}function c(t){return r(t,7)^r(t,18)^n(t,3)}function s(t){return r(t,17)^r(t,19)^n(t,10)}var f=8,l=0;return t=function(t){t=t.replace(/\r\n/g,"\n");for(var e="",r=0;r127&&n<2048?(e+=String.fromCharCode(n>>6|192),e+=String.fromCharCode(63&n|128)):(e+=String.fromCharCode(n>>12|224),e+=String.fromCharCode(n>>6&63|128),e+=String.fromCharCode(63&n|128))}return e}(t),function(t){for(var e=l?"0123456789ABCDEF":"0123456789abcdef",r="",n=0;n<4*t.length;n++)r+=e.charAt(t[n>>2]>>8*(3-n%4)+4&15)+e.charAt(t[n>>2]>>8*(3-n%4)&15);return r}(function(t,r){var n=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],f=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],l=new Array(64),y=void 0,d=void 0,m=void 0,h=void 0,p=void 0,g=void 0,v=void 0,T=void 0,S=void 0,M=void 0;t[r>>5]|=128<<24-r%32,t[15+(r+64>>9<<4)]=r;for(var b=0;b>5]|=(t.charCodeAt(n/f)&r)<<24-n%32;return e}(t),t.length*f))}t.exports=n}]); \ No newline at end of file + var katch=function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=4)}([function(t,e,r){"use strict";function n(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function i(t){if(l===setTimeout)return setTimeout(t,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(t,0);try{return l(t,0)}catch(e){try{return l.call(null,t,0)}catch(e){return l.call(this,t,0)}}}function a(t){if(y===clearTimeout)return clearTimeout(t);if((y===o||!y)&&clearTimeout)return y=clearTimeout,clearTimeout(t);try{return y(t)}catch(e){try{return y.call(null,t)}catch(e){return y.call(this,t)}}}function u(){g&&m&&(g=!1,m.length?h=m.concat(h):p=-1,h.length&&s())}function s(){if(!g){var t=i(u);g=!0;for(var e=h.length;e;){for(m=h,h=[];++p1)for(var r=1;r0&&void 0!==arguments[0]?arguments[0]:"all",e=new Date;return"date"===t?o(e,"yyyy-mm-dd"):"time"===t?o(e,"HH:MM:ss"):o(e,"yyyy-mm-dd HH:MM:ss")},i.isServer=function(){return void 0!==e},i.isBrowser=function(){return"undefined"!=typeof window},t.exports=i}).call(e,r(0))},function(t,e,r){"use strict";var n={};n.events=[],n.on=function(t,e){n.events.push(t,e)},n.fire=function(){for(var t=arguments.length,e=Array(t),r=0;r1&&void 0!==arguments[1]?arguments[1]:{},r={time:i.getLocaleISODate(),type:"ERROR",hash:s(t.stack),message:t.stack,params:e};u.fire("error",t,e),u.fire("type"+t.name,t,e),a.write(r,n.config)},n.captureError=n.error,n.info=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={time:i.getLocaleISODate(),type:"INFO",hash:s(t),message:t,params:e,objectType:null};u.fire("info",t,e),a.write(r,n.config)},n.wrap=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{t()}catch(t){n.captureError(t,e)}},n.on=u.on,t.exports=n}).call(e,r(0))},function(t,e,r){"use strict";var n,o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(i){function a(t,e){for(t=String(t),e=e||2;t.length0?"-":"+")+a(100*Math.floor(Math.abs(b)/60)+Math.abs(b)%60,4),S:["th","st","nd","rd"][m%10>3?0:(m%100-m%10!=10)*m%10],W:w,N:D};return o.replace(t,function(t){return t in C?C[t]:t.slice(1,t.length-1)})}}();f.masks={default:"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:sso",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'",expiresHeaderFormat:"ddd, dd mmm yyyy HH:MM:ss Z"},f.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]},void 0!==(n=function(){return f}.call(e,r,e,t))&&(t.exports=n)}()},function(t,e,r){"use strict";(function(e){var n=r(1),o=r(2),i=r(3),a=r(3),u={};u.write=function(t,r){if(n.isBrowser()){if(t.useragent=navigator.userAgent,r.logging){var u=n.getLocaleISODate("date"),s=JSON.parse(localStorage.getItem("katch"))||{};s[u]||(s[u]=[]),s[u].push(t);try{localStorage.setItem("katch",JSON.stringify(s))}catch(t){localStorage.clear(),localStorage.setItem("katch",JSON.stringify(s))}}}else{var c=n.getLocaleISODate("date")+".log",f=r.writeFile.folderPath,l="",y=r.writeFile.prefix;if(t.host=a.hostname(),t.pid=e.pid,t.platform=e.platform,r.logging){if(r.writeFile.humanize){l="["+t.time+"] ["+t.type+"] ["+t.host+"] ["+t.hash+"] \n"+t.message+"\n------------------------------------------------------------------------------------\n"}else l=JSON.stringify(t)+"\n";r.writeFile&&(i.existsSync(f)||i.mkdirSync(f),i.appendFileSync(f+"/"+y+c,l))}}o.fire("log",t)},t.exports=u}).call(e,r(0))},function(t,e,r){"use strict";function n(t){function e(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function r(t,e){return t>>>e|t<<32-e}function n(t,e){return t>>>e}function o(t,e,r){return t&e^~t&r}function i(t,e,r){return t&e^t&r^e&r}function a(t){return r(t,2)^r(t,13)^r(t,22)}function u(t){return r(t,6)^r(t,11)^r(t,25)}function s(t){return r(t,7)^r(t,18)^n(t,3)}function c(t){return r(t,17)^r(t,19)^n(t,10)}var f=8,l=0;return t=function(t){t=t.replace(/\r\n/g,"\n");for(var e="",r=0;r127&&n<2048?(e+=String.fromCharCode(n>>6|192),e+=String.fromCharCode(63&n|128)):(e+=String.fromCharCode(n>>12|224),e+=String.fromCharCode(n>>6&63|128),e+=String.fromCharCode(63&n|128))}return e}(t),function(t){for(var e=l?"0123456789ABCDEF":"0123456789abcdef",r="",n=0;n<4*t.length;n++)r+=e.charAt(t[n>>2]>>8*(3-n%4)+4&15)+e.charAt(t[n>>2]>>8*(3-n%4)&15);return r}(function(t,r){var n=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],f=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],l=new Array(64),y=void 0,d=void 0,m=void 0,h=void 0,g=void 0,p=void 0,v=void 0,T=void 0,S=void 0,M=void 0;t[r>>5]|=128<<24-r%32,t[15+(r+64>>9<<4)]=r;for(var b=0;b>5]|=(t.charCodeAt(n/f)&r)<<24-n%32;return e}(t),t.length*f))}t.exports=n}]); \ No newline at end of file