Skip to content

Commit

Permalink
feat: remove support for old logger(); chore: clean up code; chore: u…
Browse files Browse the repository at this point in the history
…pdate example
  • Loading branch information
Eugene Rodionov committed Sep 25, 2015
1 parent 80cd180 commit 694daf2
Show file tree
Hide file tree
Showing 32 changed files with 535 additions and 530 deletions.
7 changes: 6 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
"__DEV__": true
},
"rules": {
"valid-jsdoc": 2,
"no-else-return": 0,
"no-extend-native": 0,
"no-console": 0,
"no-else-return": 0
"quotes": [2, "backtick"],
"jsx-quotes": 2,
"new-cap": 0,
},
"plugins": [
"react"
Expand Down
43 changes: 24 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,46 @@ __createLogger(options?: Object)__
#### __level (String)__
Level of `console`. `warn`, `error`, `info` or [else](https://developer.mozilla.org/en/docs/Web/API/console).

*Default: `console.log`*
*Default: `log`*

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

*Default: `window.console`*

#### __timestamp (Boolean)__
Print timestamp with each action?
#### __collapsed (getState: Function, action: 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: `true`*
*Default: `false`*

#### __predicate (getState: Function, action: Object): boolean__
If specified this function will be called before each action is processed with this middleware.
Receives `getState` function for accessing current store state and `action` object as parameters. Returns `true` if action should be logged, `false` otherwise.

*Default: `null` (always log)*

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

*Default: `false`*

#### __timestamp (Boolean)__
Print timestamp with each action?

*Default: `true`*

#### __transformer (Function)__
Transform state before print. Eg. convert Immutable object to plain JSON.

*Default: identity function*

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

*Default: `null` (always log)*

#### __collapsed (getState: Function, action: 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`*
*Default: identity function*

##### Examples:
###### log only in dev mode
### Examples:
#### log only in dev mode
```javascript
const __DEV__ = true;

Expand All @@ -72,28 +77,28 @@ createLogger({
});
```

###### log everything except actions with type `AUTH_REMOVE_TOKEN`
#### log everything except actions with type `AUTH_REMOVE_TOKEN`
```javascript
createLogger({
predicate: (getState, action) => action.type !== AUTH_REMOVE_TOKEN
});
```

###### collapse all actions
#### collapse all actions
```javascript
createLogger({
collapsed: true
});
```

###### collapse actions with type `FORM_CHANGE`
#### collapse actions with type `FORM_CHANGE`
```javascript
createLogger({
collapsed: (getState, action) => action.type === FORM_CHANGE
});
```

###### transform Immutable objects into JSON
#### transform Immutable objects into JSON
```javascript
createLogger({
transformer: (state) => {
Expand Down
111 changes: 0 additions & 111 deletions build/createLogger.js

This file was deleted.

33 changes: 0 additions & 33 deletions build/index.js

This file was deleted.

48 changes: 0 additions & 48 deletions build/logger.js

This file was deleted.

1 change: 1 addition & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/index.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions example/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"stage": 0,
"plugins": [
"react-transform"
],
"extra": {
"react-transform": {
"transforms": [{
"transform": "react-transform-hmr",
"imports": ["react"],
"locals": ["module"]
}]
}
}
}
33 changes: 33 additions & 0 deletions example/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"extends": "airbnb",
"env": {
"browser": true,
"mocha": true,
"node": true
},
"rules": {
"valid-jsdoc": 2,
"no-else-return": 0,
"no-extend-native": 0,
"no-console": 0,
"quotes": [2, "backtick"],
"jsx-quotes": 2,
"new-cap": 0,

"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/react-in-jsx-scope": 2,
"react/prop-types": 0,
"react/jsx-quotes": 0,
"react/sort-comp": [2, {
"order": [
"lifecycle",
"everything-else",
"render"
],
}]
},
"plugins": [
"react"
]
}
2 changes: 1 addition & 1 deletion example/actions/auth.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AUTH_SET_TOKEN, AUTH_SET_INFO, AUTH_REMOVE_TOKEN } from '../constants/auth';
import { AUTH_SET_TOKEN, AUTH_SET_INFO, AUTH_REMOVE_TOKEN } from 'constants/auth';

export function setToken(token) {
return {
Expand Down
2 changes: 1 addition & 1 deletion example/actions/properties.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PROPERTIES_UPDATE } from '../constants/properties';
import { PROPERTIES_UPDATE } from 'constants/properties';

export function updateProperties(list) {
return {
Expand Down
Loading

0 comments on commit 694daf2

Please sign in to comment.