Skip to content

Commit 694daf2

Browse files
author
Eugene Rodionov
committed
feat: remove support for old logger(); chore: clean up code; chore: update example
1 parent 80cd180 commit 694daf2

32 files changed

+535
-530
lines changed

.eslintrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
"__DEV__": true
1010
},
1111
"rules": {
12+
"valid-jsdoc": 2,
13+
"no-else-return": 0,
14+
"no-extend-native": 0,
1215
"no-console": 0,
13-
"no-else-return": 0
16+
"quotes": [2, "backtick"],
17+
"jsx-quotes": 2,
18+
"new-cap": 0,
1419
},
1520
"plugins": [
1621
"react"

README.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,41 +29,46 @@ __createLogger(options?: Object)__
2929
#### __level (String)__
3030
Level of `console`. `warn`, `error`, `info` or [else](https://developer.mozilla.org/en/docs/Web/API/console).
3131

32-
*Default: `console.log`*
32+
*Default: `log`*
3333

3434
#### __logger (Object)__
3535
Implementation of the `console` API. Useful if you are using a custom, wrapped version of `console`.
3636

3737
*Default: `window.console`*
3838

39-
#### __timestamp (Boolean)__
40-
Print timestamp with each action?
39+
#### __collapsed (getState: Function, action: Object): boolean__
40+
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.
4141

42-
*Default: `true`*
42+
*Default: `false`*
43+
44+
#### __predicate (getState: Function, action: Object): boolean__
45+
If specified this function will be called before each action is processed with this middleware.
46+
Receives `getState` function for accessing current store state and `action` object as parameters. Returns `true` if action should be logged, `false` otherwise.
47+
48+
*Default: `null` (always log)*
4349

4450
#### __duration (Boolean)__
4551
Print duration of each action?
4652

4753
*Default: `false`*
4854

55+
#### __timestamp (Boolean)__
56+
Print timestamp with each action?
57+
58+
*Default: `true`*
59+
4960
#### __transformer (Function)__
5061
Transform state before print. Eg. convert Immutable object to plain JSON.
5162

5263
*Default: identity function*
5364

54-
#### __predicate (getState: Function, action: Object): boolean__
55-
If specified this function will be called before each action is processed with this middleware.
56-
Receives `getState` function for accessing current store state and `action` object as parameters. Returns `true` if action should be logged, `false` otherwise.
65+
#### __actionTransformer (Function)__
66+
Transform action before print. Eg. convert Immutable object to plain JSON.
5767

58-
*Default: `null` (always log)*
59-
60-
#### __collapsed (getState: Function, action: Object): boolean__
61-
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.
62-
63-
*Default: `false`*
68+
*Default: identity function*
6469

65-
##### Examples:
66-
###### log only in dev mode
70+
### Examples:
71+
#### log only in dev mode
6772
```javascript
6873
const __DEV__ = true;
6974

@@ -72,28 +77,28 @@ createLogger({
7277
});
7378
```
7479

75-
###### log everything except actions with type `AUTH_REMOVE_TOKEN`
80+
#### log everything except actions with type `AUTH_REMOVE_TOKEN`
7681
```javascript
7782
createLogger({
7883
predicate: (getState, action) => action.type !== AUTH_REMOVE_TOKEN
7984
});
8085
```
8186

82-
###### collapse all actions
87+
#### collapse all actions
8388
```javascript
8489
createLogger({
8590
collapsed: true
8691
});
8792
```
8893

89-
###### collapse actions with type `FORM_CHANGE`
94+
#### collapse actions with type `FORM_CHANGE`
9095
```javascript
9196
createLogger({
9297
collapsed: (getState, action) => action.type === FORM_CHANGE
9398
});
9499
```
95100

96-
###### transform Immutable objects into JSON
101+
#### transform Immutable objects into JSON
97102
```javascript
98103
createLogger({
99104
transformer: (state) => {

build/createLogger.js

Lines changed: 0 additions & 111 deletions
This file was deleted.

build/index.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

build/logger.js

Lines changed: 0 additions & 48 deletions
This file was deleted.

dist/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/.babelrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"stage": 0,
3+
"plugins": [
4+
"react-transform"
5+
],
6+
"extra": {
7+
"react-transform": {
8+
"transforms": [{
9+
"transform": "react-transform-hmr",
10+
"imports": ["react"],
11+
"locals": ["module"]
12+
}]
13+
}
14+
}
15+
}

example/.eslintrc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"extends": "airbnb",
3+
"env": {
4+
"browser": true,
5+
"mocha": true,
6+
"node": true
7+
},
8+
"rules": {
9+
"valid-jsdoc": 2,
10+
"no-else-return": 0,
11+
"no-extend-native": 0,
12+
"no-console": 0,
13+
"quotes": [2, "backtick"],
14+
"jsx-quotes": 2,
15+
"new-cap": 0,
16+
17+
"react/jsx-uses-react": 2,
18+
"react/jsx-uses-vars": 2,
19+
"react/react-in-jsx-scope": 2,
20+
"react/prop-types": 0,
21+
"react/jsx-quotes": 0,
22+
"react/sort-comp": [2, {
23+
"order": [
24+
"lifecycle",
25+
"everything-else",
26+
"render"
27+
],
28+
}]
29+
},
30+
"plugins": [
31+
"react"
32+
]
33+
}

example/actions/auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AUTH_SET_TOKEN, AUTH_SET_INFO, AUTH_REMOVE_TOKEN } from '../constants/auth';
1+
import { AUTH_SET_TOKEN, AUTH_SET_INFO, AUTH_REMOVE_TOKEN } from 'constants/auth';
22

33
export function setToken(token) {
44
return {

0 commit comments

Comments
 (0)