Skip to content

Commit eda2ba4

Browse files
committed
feat: indent action and error titles
1 parent dbfd4f9 commit eda2ba4

File tree

4 files changed

+8
-20
lines changed

4 files changed

+8
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ coverage
1010
example/build
1111
dist
1212
lib
13+
yarn.lock

example/src/index.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,22 @@ import 'styles/base';
33

44
import React from 'react';
55
import { render } from 'react-dom';
6-
import createLogger from 'redux-logger';
6+
import createLogger, { defaults } from '../../src';
77

88
import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
99
import { Provider } from 'react-redux';
1010

1111
import Example from 'components/example';
1212
import reducers from 'reducers';
13-
import { AUTH_REMOVE_TOKEN, AUTH_SET_INFO, AUTH_SET_TOKEN } from 'constants/auth';
13+
import { AUTH_REMOVE_TOKEN, AUTH_SET_TOKEN } from 'constants/auth';
1414

1515
const logger = createLogger({
1616
predicate: (getState, action) => action.type !== AUTH_REMOVE_TOKEN, // log all actions except AUTH_REMOVE_TOKEN
17-
level: {
18-
prevState: () => `info`,
19-
action: ({ type }) => type === AUTH_SET_INFO ? `error` : `log`,
20-
error: () => `error`,
21-
nextState: () => `info`,
22-
},
2317
duration: true,
24-
actionTransformer: (action) => ({
25-
...action,
26-
type: String(action.type),
27-
}),
2818
colors: {
29-
prevState: () => `#FFEB3B`,
30-
action: ({ type }) => type === AUTH_SET_INFO && `red`,
31-
nextState: () => `#4CAF50`,
19+
...defaults.colors,
20+
action: ({ type }) => type === AUTH_SET_TOKEN && `green`,
3221
},
33-
diff: true,
34-
diffPredicate: (getState, action) => action.type === AUTH_SET_TOKEN,
3522
});
3623

3724
const reducer = combineReducers(reducers);

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.9.0",
3+
"version": "2.9.1",
44
"description": "Logger for Redux",
55
"main": "lib/index.js",
66
"scripts": {

src/core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ export function printBuffer(buffer, options) {
9393

9494
if (actionLevel) {
9595
if (colors.action) logger[actionLevel](`%c action`, `color: ${colors.action(formattedAction)}; font-weight: bold`, formattedAction);
96-
else logger[actionLevel](`action`, formattedAction);
96+
else logger[actionLevel](`action `, formattedAction);
9797
}
9898

9999
if (error && errorLevel) {
100100
if (colors.error) logger[errorLevel](`%c error`, `color: ${colors.error(error, prevState)}; font-weight: bold`, error);
101-
else logger[errorLevel](`error`, error);
101+
else logger[errorLevel](`error `, error);
102102
}
103103

104104
if (nextStateLevel) {

0 commit comments

Comments
 (0)