2018-12-23 07:56:44 -06:00
|
|
|
const debugActionIgnore = (process.env.DEBUG_ACTION_IGNORE || '').split(',');
|
|
|
|
|
|
|
|
export function createDebugAction(debug, action) {
|
|
|
|
if (!debug.enabled || -1 !== debugActionIgnore.indexOf(action.type)) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
const debugAction = {type: action.type, payload: {...action.payload}};
|
|
|
|
if (!process.env.SILLY_DEBUG) {
|
|
|
|
for (const i in debugAction.payload) {
|
2018-12-24 13:21:18 -06:00
|
|
|
// Exceptions...
|
|
|
|
if (
|
|
|
|
// Invocation hook.
|
2019-03-05 19:21:09 -06:00
|
|
|
-1 !== ['@truss/invoke', '@truss/invoke-flat'] && i !== 'hook'
|
2018-12-24 13:21:18 -06:00
|
|
|
) {
|
|
|
|
debugAction.payload[i] = '[...]';
|
|
|
|
}
|
2018-12-23 07:56:44 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return debugAction;
|
|
|
|
}
|