Skip to content

Commit cae12d8

Browse files
jedwards1211imevro
authored andcommitted
feat: pass logEntry to collapsed function (#200)
1 parent 8c916d0 commit cae12d8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ on error" in dev tools harder to use, as it breaks on re-throw rather than the o
119119

120120
*Default: `true`*
121121

122-
#### __collapsed = (getState: Function, action: Object) => Boolean__
122+
#### __collapsed = (getState: Function, action: Object, logEntry: Object) => Boolean__
123123
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.
124124

125125
*Default: `false`*
@@ -202,6 +202,13 @@ createLogger({
202202
});
203203
```
204204

205+
### Collapse actions that don't have errors
206+
```javascript
207+
createLogger({
208+
collapsed: (getState, action, logEntry) => !logEntry.error
209+
});
210+
```
211+
205212
### Transform Immutable (without `combineReducers`)
206213
```javascript
207214
import { Iterable } from 'immutable';

src/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function printBuffer(buffer, options) {
6060

6161
// Message
6262
const formattedAction = actionTransformer(action);
63-
const isCollapsed = (typeof collapsed === `function`) ? collapsed(() => nextState, action) : collapsed;
63+
const isCollapsed = (typeof collapsed === `function`) ? collapsed(() => nextState, action, logEntry) : collapsed;
6464

6565
const formattedTime = formatTime(startedTime);
6666
const titleCSS = colors.title ? `color: ${colors.title(formattedAction)};` : null;

0 commit comments

Comments
 (0)