From cae12d84c323c26bcc1ada844f7ea5defd762635 Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Wed, 1 Feb 2017 04:06:35 -0600 Subject: [PATCH] feat: pass logEntry to collapsed function (#200) --- README.md | 9 ++++++++- src/core.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 91642d8..b041f85 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ on error" in dev tools harder to use, as it breaks on re-throw rather than the o *Default: `true`* -#### __collapsed = (getState: Function, action: Object) => Boolean__ +#### __collapsed = (getState: Function, action: Object, logEntry: Object) => Boolean__ Takes a boolean or optionally a function that receives `getState` function for accessing current store state and `action` object as parameters. Returns `true` if the log group should be collapsed, `false` otherwise. *Default: `false`* @@ -202,6 +202,13 @@ createLogger({ }); ``` +### Collapse actions that don't have errors +```javascript +createLogger({ + collapsed: (getState, action, logEntry) => !logEntry.error +}); +``` + ### Transform Immutable (without `combineReducers`) ```javascript import { Iterable } from 'immutable'; diff --git a/src/core.js b/src/core.js index 20a0346..f162d49 100644 --- a/src/core.js +++ b/src/core.js @@ -60,7 +60,7 @@ export function printBuffer(buffer, options) { // Message const formattedAction = actionTransformer(action); - const isCollapsed = (typeof collapsed === `function`) ? collapsed(() => nextState, action) : collapsed; + const isCollapsed = (typeof collapsed === `function`) ? collapsed(() => nextState, action, logEntry) : collapsed; const formattedTime = formatTime(startedTime); const titleCSS = colors.title ? `color: ${colors.title(formattedAction)};` : null;