@jarvisaoieong/redux-logger
Advanced tools
Comparing version
@@ -80,2 +80,10 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var renderActionType = function renderActionType(action) { | ||
var subActionType = ''; | ||
if (action.action) { | ||
subActionType = ' > ' + renderActionType(action.action); | ||
}; | ||
return '' + action.type + subActionType; | ||
}; | ||
/** | ||
@@ -181,3 +189,3 @@ * Creates logger with followed options | ||
var originalActionType = originalActions.map(function (action) { | ||
return action.type + ' > '; | ||
return renderActionType(action) + ' >> '; | ||
}).join(''); | ||
@@ -193,3 +201,3 @@ | ||
var titleCSS = colors.title ? 'color: ' + colors.title(formattedAction) + ';' : null; | ||
var title = (isLoop ? '⌛ ' : '') + 'action ' + (isLoop ? originalActionType : '') + formattedAction.type + (timestamp ? formattedTime : '') + (duration ? ' in ' + took.toFixed(2) + ' ms' : ''); | ||
var title = (isLoop ? '⌛ ' : '') + 'action ' + (isLoop ? originalActionType : '') + renderActionType(formattedAction) + (timestamp ? formattedTime : '') + (duration ? ' in ' + took.toFixed(2) + ' ms' : ''); | ||
@@ -196,0 +204,0 @@ // render |
@@ -1,1 +0,1 @@ | ||
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.reduxLogger=r():t.reduxLogger=r()}(this,function(){return function(t){function r(o){if(e[o])return e[o].exports;var n=e[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,r),n.loaded=!0,n.exports}var e={};return r.m=t,r.c=e,r.p="",r(0)}([function(t,r,e){e(1),t.exports=e(1)},function(t,r){"use strict";function e(){function t(){A.forEach(function(t,r){var e=t.started,n=t.action,a=t.prevState,u=t.error,f=t.originalActions,d=t.took,l=t.nextState,g=A[r+1];g&&(l=g.prevState,d=g.started-e);var m=f.length,x=f.map(function(t){return t.type+" > "}).join(""),h=S(n),y=new Date(e),w="function"==typeof s?s(function(){return l},n):s,b=i(y),E=j.title?"color: "+j.title(h)+";":null,F=(m?"⌛ ":"")+"action "+(m?x:"")+h.type+(v?b:"")+(p?" in "+d.toFixed(2)+" ms":"");try{w?j.title?c.groupCollapsed("%c "+F,E):c.groupCollapsed(F):j.title?c.group("%c "+F,E):c.group(F)}catch(T){c.log(F)}j.prevState?c[o]("%c prev state","color: "+j.prevState(a)+"; font-weight: bold",a):c[o]("prev state",a),m&&(j.action?c[o]("%c original actions","color: "+j.action(f)+"; font-weight: bold",f):c[o]("action",f)),j.action?c[o]("%c action","color: "+j.action(h)+"; font-weight: bold",h):c[o]("action",h),u&&(j.error?c[o]("%c error","color: "+j.error(u,a)+"; font-weight: bold",u):c[o]("error",u)),j.nextState?c[o]("%c next state","color: "+j.nextState(l)+"; font-weight: bold",l):c[o]("next state",l);try{c.groupEnd()}catch(T){c.log("—— log end ——")}}),A.length=0}var r=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=r.level,o=void 0===e?"log":e,n=r.logger,c=void 0===n?window.console:n,u=r.logErrors,f=void 0===u?!0:u,s=r.collapsed,d=r.predicate,l=r.duration,p=void 0===l?!1:l,g=r.timestamp,v=void 0===g?!0:g,m=r.transformer,x=r.stateTransformer,h=void 0===x?function(t){return t}:x,y=r.actionTransformer,S=void 0===y?function(t){return t}:y,w=r.errorTransformer,b=void 0===w?function(t){return t}:w,E=r.colors,j=void 0===E?{title:function(){return"#000000"},prevState:function(){return"#9E9E9E"},action:function(){return"#03A9F4"},nextState:function(){return"#4CAF50"},error:function(){return"#F20404"}}:E;if("undefined"==typeof c)return function(){return function(t){return function(r){return t(r)}}};m&&console.error("Option 'transformer' is deprecated, use stateTransformer instead");var A=[];return function(r){var e=r.getState;return function(r){return function(o){var n=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];if("function"==typeof d&&!d(e,o))return r(o,n);var i={};A.push(i),i.started=a.now(),i.prevState=h(e()),i.action=o,i.originalActions=n;var c=void 0;if(f)try{c=r(o)}catch(u){i.error=b(u)}else c=r(o);if(i.took=a.now()-i.started,i.nextState=h(e()),t(),i.error)throw i.error;return c}}}}var o=function(t,r){return new Array(r+1).join(t)},n=function(t,r){return o("0",r-t.toString().length)+t},i=function(t){return" @ "+n(t.getHours(),2)+":"+n(t.getMinutes(),2)+":"+n(t.getSeconds(),2)+"."+n(t.getMilliseconds(),3)},a="undefined"!=typeof performance&&"function"==typeof performance.now?performance:Date;t.exports=e}])}); | ||
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.reduxLogger=r():t.reduxLogger=r()}(this,function(){return function(t){function r(o){if(e[o])return e[o].exports;var n=e[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,r),n.loaded=!0,n.exports}var e={};return r.m=t,r.c=e,r.p="",r(0)}([function(t,r,e){e(1),t.exports=e(1)},function(t,r){"use strict";function e(){function t(){F.forEach(function(t,r){var e=t.started,n=t.action,a=t.prevState,f=t.error,s=t.originalActions,l=t.took,p=t.nextState,v=F[r+1];v&&(p=v.prevState,l=v.started-e);var x=s.length,h=s.map(function(t){return c(t)+" >> "}).join(""),y=w(n),S=new Date(e),b="function"==typeof d?d(function(){return p},n):d,E=i(S),j=A.title?"color: "+A.title(y)+";":null,T=(x?"⌛ ":"")+"action "+(x?h:"")+c(y)+(m?E:"")+(g?" in "+l.toFixed(2)+" ms":"");try{b?A.title?u.groupCollapsed("%c "+T,j):u.groupCollapsed(T):A.title?u.group("%c "+T,j):u.group(T)}catch(C){u.log(T)}A.prevState?u[o]("%c prev state","color: "+A.prevState(a)+"; font-weight: bold",a):u[o]("prev state",a),x&&(A.action?u[o]("%c original actions","color: "+A.action(s)+"; font-weight: bold",s):u[o]("action",s)),A.action?u[o]("%c action","color: "+A.action(y)+"; font-weight: bold",y):u[o]("action",y),f&&(A.error?u[o]("%c error","color: "+A.error(f,a)+"; font-weight: bold",f):u[o]("error",f)),A.nextState?u[o]("%c next state","color: "+A.nextState(p)+"; font-weight: bold",p):u[o]("next state",p);try{u.groupEnd()}catch(C){u.log("—— log end ——")}}),F.length=0}var r=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=r.level,o=void 0===e?"log":e,n=r.logger,u=void 0===n?window.console:n,f=r.logErrors,s=void 0===f?!0:f,d=r.collapsed,l=r.predicate,p=r.duration,g=void 0===p?!1:p,v=r.timestamp,m=void 0===v?!0:v,x=r.transformer,h=r.stateTransformer,y=void 0===h?function(t){return t}:h,S=r.actionTransformer,w=void 0===S?function(t){return t}:S,b=r.errorTransformer,E=void 0===b?function(t){return t}:b,j=r.colors,A=void 0===j?{title:function(){return"#000000"},prevState:function(){return"#9E9E9E"},action:function(){return"#03A9F4"},nextState:function(){return"#4CAF50"},error:function(){return"#F20404"}}:j;if("undefined"==typeof u)return function(){return function(t){return function(r){return t(r)}}};x&&console.error("Option 'transformer' is deprecated, use stateTransformer instead");var F=[];return function(r){var e=r.getState;return function(r){return function(o){var n=arguments.length<=1||void 0===arguments[1]?[]:arguments[1];if("function"==typeof l&&!l(e,o))return r(o,n);var i={};F.push(i),i.started=a.now(),i.prevState=y(e()),i.action=o,i.originalActions=n;var c=void 0;if(s)try{c=r(o)}catch(u){i.error=E(u)}else c=r(o);if(i.took=a.now()-i.started,i.nextState=y(e()),t(),i.error)throw i.error;return c}}}}var o=function(t,r){return new Array(r+1).join(t)},n=function(t,r){return o("0",r-t.toString().length)+t},i=function(t){return" @ "+n(t.getHours(),2)+":"+n(t.getMinutes(),2)+":"+n(t.getSeconds(),2)+"."+n(t.getMilliseconds(),3)},a="undefined"!=typeof performance&&"function"==typeof performance.now?performance:Date,c=function u(t){var r="";return t.action&&(r=" > "+u(t.action)),""+t.type+r};t.exports=e}])}); |
@@ -16,2 +16,10 @@ 'use strict'; | ||
var renderActionType = function renderActionType(action) { | ||
var subActionType = ''; | ||
if (action.action) { | ||
subActionType = ' > ' + renderActionType(action.action); | ||
}; | ||
return '' + action.type + subActionType; | ||
}; | ||
/** | ||
@@ -117,3 +125,3 @@ * Creates logger with followed options | ||
var originalActionType = originalActions.map(function (action) { | ||
return action.type + ' > '; | ||
return renderActionType(action) + ' >> '; | ||
}).join(''); | ||
@@ -129,3 +137,3 @@ | ||
var titleCSS = colors.title ? 'color: ' + colors.title(formattedAction) + ';' : null; | ||
var title = (isLoop ? '⌛ ' : '') + 'action ' + (isLoop ? originalActionType : '') + formattedAction.type + (timestamp ? formattedTime : '') + (duration ? ' in ' + took.toFixed(2) + ' ms' : ''); | ||
var title = (isLoop ? '⌛ ' : '') + 'action ' + (isLoop ? originalActionType : '') + renderActionType(formattedAction) + (timestamp ? formattedTime : '') + (duration ? ' in ' + took.toFixed(2) + ' ms' : ''); | ||
@@ -132,0 +140,0 @@ // render |
{ | ||
"name": "@jarvisaoieong/redux-logger", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "Logger for redux", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -8,2 +8,10 @@ const repeat = (str, times) => (new Array(times + 1)).join(str); | ||
const renderActionType = (action) => { | ||
let subActionType = ''; | ||
if (action.action) { | ||
subActionType = ` > ${renderActionType(action.action)}`; | ||
}; | ||
return `${action.type}${subActionType}`; | ||
} | ||
/** | ||
@@ -70,3 +78,5 @@ * Creates logger with followed options | ||
const isLoop = originalActions.length; | ||
const originalActionType = originalActions.map((action) => action.type + ` > `).join(``); | ||
const originalActionType = originalActions.map((action) => | ||
`${renderActionType(action)} >> ` | ||
).join(``); | ||
@@ -79,3 +89,3 @@ const formattedAction = actionTransformer(action); | ||
const titleCSS = colors.title ? `color: ${colors.title(formattedAction)};` : null; | ||
const title = `${isLoop ? '⌛ ': ''}action ${isLoop ? originalActionType : ``}${formattedAction.type}${timestamp ? formattedTime : ``}${duration ? ` in ${took.toFixed(2)} ms` : ``}`; | ||
const title = `${isLoop ? '⌛ ': ''}action ${isLoop ? originalActionType : ``}${renderActionType(formattedAction)}${timestamp ? formattedTime : ``}${duration ? ` in ${took.toFixed(2)} ms` : ``}`; | ||
@@ -82,0 +92,0 @@ // render |
35300
2.38%561
4.28%