Skip to content

Commit 16d588e

Browse files
committed
feat: implicitly convert action.type to string
1 parent 904329c commit 16d588e

File tree

4 files changed

+17
-25
lines changed

4 files changed

+17
-25
lines changed

README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* [API](#api)
1313
* [Recipes](#recipes)
1414
* [Log only in development](#log-only-in-development)
15-
* [Transform `Symbol()` action type to string](#transform-symbol-action-type-to-string)
1615
* [Log everything except actions with certain type](#log-everything-except-actions-with-certain-type)
1716
* [Collapse actions with certain type](#collapse-actions-with-certain-type)
1817
* [Transform Immutable (without `combineReducers`)](#transform-immutable-without-combinereducers)
@@ -176,18 +175,6 @@ if (process.env.NODE_ENV === `development`) {
176175
const store = compose(applyMiddleware(...middlewares))(createStore)(reducer);
177176
```
178177

179-
### Transform `Symbol()` action type to string
180-
```javascript
181-
import createLogger from 'redux-logger';
182-
183-
const logger = createLogger({
184-
actionTransformer: (action) => ({
185-
...action,
186-
type: String(action.type),
187-
})
188-
});
189-
```
190-
191178
### Log everything except actions with certain type
192179
```javascript
193180
createLogger({

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "redux-logger",
3-
"version": "2.8.0",
3+
"version": "2.8.1",
44
"description": "Logger for Redux",
55
"main": "lib/index.js",
66
"scripts": {

src/core.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,17 @@ function getLogLevel(level, action, payload, type) {
2424

2525
function defaultTitleFormatter(options) {
2626
const {
27-
timestamp, duration,
27+
timestamp,
28+
duration,
2829
} = options;
2930

3031
return (action, time, took) => {
3132
const parts = [`action`];
32-
if (timestamp) {
33-
parts.push(`@ ${time}`);
34-
}
35-
parts.push(action.type);
36-
if (duration) {
37-
parts.push(`(in ${took.toFixed(2)} ms)`);
38-
}
33+
34+
if (timestamp) parts.push(`@ ${time}`);
35+
parts.push(String(action.type));
36+
if (duration) parts.push(`(in ${took.toFixed(2)} ms)`);
37+
3938
return parts.join(` `);
4039
};
4140
}
@@ -45,7 +44,10 @@ export function printBuffer(buffer, options) {
4544
logger,
4645
actionTransformer,
4746
titleFormatter = defaultTitleFormatter(options),
48-
collapsed, colors, level, diff,
47+
collapsed,
48+
colors,
49+
level,
50+
diff,
4951
} = options;
5052

5153
buffer.forEach((logEntry, key) => {

src/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ function createLogger(options = {}) {
2929

3030
const {
3131
logger,
32-
transformer, stateTransformer, errorTransformer,
33-
predicate, logErrors,
32+
transformer,
33+
stateTransformer,
34+
errorTransformer,
35+
predicate,
36+
logErrors,
3437
diffPredicate,
3538
} = loggerOptions;
3639

0 commit comments

Comments
 (0)