{ "_args": [ [ { "raw": "redux-logger@^2.7.4", "scope": null, "escapedName": "redux-logger", "name": "redux-logger", "rawSpec": "^2.7.4", "spec": ">=2.7.4 <3.0.0", "type": "range" }, "/home/jdaugherty/work/GT2/GT2-Android/node_modules/xdl" ] ], "_from": "redux-logger@>=2.7.4 <3.0.0", "_id": "redux-logger@2.10.2", "_inCache": true, "_location": "/redux-logger", "_nodeVersion": "7.2.0", "_npmOperationalInternal": { "host": "packages-18-east.internal.npmjs.com", "tmp": "tmp/redux-logger-2.10.2.tgz_1490176746176_0.945808432996273" }, "_npmUser": { "name": "evgenyrodionov", "email": "npm@erodionov.ru" }, "_npmVersion": "4.4.1", "_phantomChildren": {}, "_requested": { "raw": "redux-logger@^2.7.4", "scope": null, "escapedName": "redux-logger", "name": "redux-logger", "rawSpec": "^2.7.4", "spec": ">=2.7.4 <3.0.0", "type": "range" }, "_requiredBy": [ "/xdl" ], "_resolved": "https://registry.npmjs.org/redux-logger/-/redux-logger-2.10.2.tgz", "_shasum": "3c5a5f0a6f32577c1deadf6655f257f82c6c3937", "_shrinkwrap": null, "_spec": "redux-logger@^2.7.4", "_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/xdl", "author": { "name": "Eugene Rodionov", "url": "https://github.com/theaqua" }, "bugs": { "url": "https://github.com/theaqua/redux-logger/issues" }, "dependencies": { "deep-diff": "0.3.4" }, "description": "Logger for Redux", "devDependencies": { "@dtrussia/eslint-config-dtrussia": "2.2.1", "babel-cli": "^6.24.0", "babel-core": "^6.24.0", "babel-eslint": "7.1.1", "babel-loader": "^6.4.1", "babel-plugin-add-module-exports": "0.2.1", "babel-plugin-transform-es2015-modules-umd": "6.24.0", "babel-plugin-transform-inline-environment-variables": "6.8.0", "babel-preset-es2015": "^6.24.0", "babel-preset-react": "^6.23.0", "babel-preset-stage-0": "^6.22.0", "chai": "3.5.0", "codecov": "1.0.1", "eslint": "3.10.2", "eslint-plugin-react": "6.7.1", "http-server": "0.9.0", "husky": "^0.13.2", "mocha": "3.1.2", "nyc": "9.0.1", "open-url": "2.0.2", "redux": "^3.6.0", "rimraf": "^2.6.1", "sinon": "^1.17.7", "webpack": "1.13.3" }, "directories": {}, "dist": { "shasum": "3c5a5f0a6f32577c1deadf6655f257f82c6c3937", "tarball": "https://registry.npmjs.org/redux-logger/-/redux-logger-2.10.2.tgz" }, "files": [ "dist", "lib", "src" ], "gitHead": "dbd6d5d1bb21c92bd9c7930c03ad16a9aae436b9", "homepage": "https://github.com/theaqua/redux-logger#readme", "keywords": [ "redux", "logger", "redux-logger", "middleware" ], "license": "MIT", "main": "lib/index.js", "maintainers": [ { "name": "evgenyrodionov", "email": "npm@erodionov.ru" }, { "name": "toxic", "email": "toxickg@openmailbox.org" } ], "name": "redux-logger", "nyc": { "exclude": [ "node_modules", "spec", "example", "lib", "dist", "webpack.*.js" ] }, "optionalDependencies": {}, "readme": "# Logger for Redux\n[![npm](https://img.shields.io/npm/v/redux-logger.svg?maxAge=2592000?style=plastic)](https://www.npmjs.com/package/redux-logger)\n[![npm](https://img.shields.io/npm/dm/redux-logger.svg?maxAge=2592000?style=plastic)](https://www.npmjs.com/package/redux-logger)\n[![Build Status](https://travis-ci.org/evgenyrodionov/redux-logger.svg?branch=master)](https://travis-ci.org/evgenyrodionov/redux-logger)\n\n![redux-logger](http://i.imgur.com/CgAuHlE.png)\n\n## Table of contents\n* [Install](#install)\n* [Usage](#usage)\n* [Options](#options)\n* [Recipes](#recipes)\n * [Log only in development](#log-only-in-development)\n * [Log everything except actions with certain type](#log-everything-except-actions-with-certain-type)\n * [Collapse actions with certain type](#collapse-actions-with-certain-type)\n * [Transform Immutable (without `combineReducers`)](#transform-immutable-without-combinereducers)\n * [Transform Immutable (with `combineReducers`)](#transform-immutable-with-combinereducers)\n * [Log batched actions](#log-batched-actions)\n* [To Do](#to-do)\n* [Known issues](#known-issues) (with `react-native` only at this moment)\n* [License](#license)\n\n## Install\n`npm i --save redux-logger`\n\n## Usage\n```javascript\nimport { applyMiddleware, createStore } from 'redux';\n\n// Logger with default options\nimport { logger } from 'redux-logger'\nconst store = createStore(\n reducer,\n applyMiddleware(logger)\n)\n\n// Note passing middleware as the third argument requires redux@>=3.1.0\n```\n\nOr you can create your own logger with custom [options](https://github.com/evgenyrodionov/redux-logger#options):\n```javascript\nimport { applyMiddleware, createStore } from 'redux';\nimport createLogger from 'redux-logger'\n\nconst logger = createLogger({\n // ...options\n});\n\nconst store = createStore(\n reducer,\n applyMiddleware(logger)\n);\n```\n\nNote: logger **must be** the last middleware in chain, otherwise it will log thunk and promise, not actual actions ([#20](https://github.com/evgenyrodionov/redux-logger/issues/20)).\n\n## Options\n```javascript\n{\n predicate, // if specified this function will be called before each action is processed with this middleware.\n collapsed, // 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.\n duration = false: Boolean, // print the duration of each action?\n timestamp = true: Boolean, // print the timestamp with each action?\n\n level = 'log': 'log' | 'console' | 'warn' | 'error' | 'info', // console's level\n colors: ColorsObject, // colors for title, prev state, action and next state: https://github.com/evgenyrodionov/redux-logger/blob/master/src/defaults.js#L12-L18\n titleFormatter, // Format the title used when logging actions.\n\n stateTransformer, // Transform state before print. Eg. convert Immutable object to plain JSON.\n actionTransformer, // Transform action before print. Eg. convert Immutable object to plain JSON.\n errorTransformer, // Transform error before print. Eg. convert Immutable object to plain JSON.\n\n logger = console: LoggerObject, // implementation of the `console` API.\n logErrors = true: Boolean, // should the logger catch, log, and re-throw errors?\n\n diff = false: Boolean, // (alpha) show diff between states?\n diffPredicate // (alpha) filter function for showing states diff, similar to `predicate`\n}\n```\n\n### Options description\n\n#### __level (String | Function | Object)__\nLevel of `console`. `warn`, `error`, `info` or [else](https://developer.mozilla.org/en/docs/Web/API/console).\n\nIt can be a function `(action: Object) => level: String`.\n\nIt can be an object with level string for: `prevState`, `action`, `nextState`, `error`\n\nIt can be an object with getter functions: `prevState`, `action`, `nextState`, `error`. Useful if you want to print\nmessage based on specific state or action. Set any of them to `false` if you want to hide it.\n\n* `prevState(prevState: Object) => level: String`\n* `action(action: Object) => level: String`\n* `nextState(nextState: Object) => level: String`\n* `error(error: Any, prevState: Object) => level: String`\n\n*Default: `log`*\n\n#### __duration (Boolean)__\nPrint duration of each action?\n\n*Default: `false`*\n\n#### __timestamp (Boolean)__\nPrint timestamp with each action?\n\n*Default: `true`*\n\n#### __colors (Object)__\nObject with color getter functions: `title`, `prevState`, `action`, `nextState`, `error`. Useful if you want to paint\nmessage based on specific state or action. Set any of them to `false` if you want to show plain message without colors.\n\n* `title(action: Object) => color: String`\n* `prevState(prevState: Object) => color: String`\n* `action(action: Object) => color: String`\n* `nextState(nextState: Object) => color: String`\n* `error(error: Any, prevState: Object) => color: String`\n\n#### __logger (Object)__\nImplementation of the `console` API. Useful if you are using a custom, wrapped version of `console`.\n\n*Default: `console`*\n\n#### __logErrors (Boolean)__\nShould the logger catch, log, and re-throw errors? This makes it clear which action triggered the error but makes \"break\non error\" in dev tools harder to use, as it breaks on re-throw rather than the original throw location.\n\n*Default: `true`*\n\n#### __collapsed = (getState: Function, action: Object, logEntry: Object) => Boolean__\nTakes 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.\n\n*Default: `false`*\n\n#### __predicate = (getState: Function, action: Object) => Boolean__\nIf specified this function will be called before each action is processed with this middleware.\nReceives `getState` function for accessing current store state and `action` object as parameters. Returns `true` if action should be logged, `false` otherwise.\n\n*Default: `null` (always log)*\n\n#### __stateTransformer = (state: Object) => state__\nTransform state before print. Eg. convert Immutable object to plain JSON.\n\n*Default: identity function*\n\n#### __actionTransformer = (action: Object) => action__\nTransform action before print. Eg. convert Immutable object to plain JSON.\n\n*Default: identity function*\n\n#### __errorTransformer = (error: Any) => error__\nTransform error before print.\n\n*Default: identity function*\n\n#### __titleFormatter = (action: Object, time: String?, took: Number?) => title__\nFormat the title used for each action.\n\n*Default: prints something like `action @ ${time} ${action.type} (in ${took.toFixed(2)} ms)`*\n\n#### __diff (Boolean)__\nShow states diff.\n\n*Default: `false`*\n\n#### __diffPredicate = (getState: Function, action: Object) => Boolean__\nFilter states diff for certain cases.\n\n*Default: `undefined`*\n\n## Recipes\n### Log only in development\n```javascript\nimport thunk from 'redux-thunk';\n\nconst middlewares = [thunk];\n\nif (process.env.NODE_ENV === `development`) {\n const { logger } = require(`redux-logger`);\n middlewares.push(logger);\n}\n\nconst store = compose(applyMiddleware(...middlewares))(createStore)(reducer);\n```\n\n### Log everything except actions with certain type\n```javascript\ncreateLogger({\n predicate: (getState, action) => action.type !== AUTH_REMOVE_TOKEN\n});\n```\n\n### Collapse actions with certain type\n```javascript\ncreateLogger({\n collapsed: (getState, action) => action.type === FORM_CHANGE\n});\n```\n\n### Collapse actions that don't have errors\n```javascript\ncreateLogger({\n collapsed: (getState, action, logEntry) => !logEntry.error\n});\n```\n\n### Transform Immutable (without `combineReducers`)\n```javascript\nimport { Iterable } from 'immutable';\n\nconst stateTransformer = (state) => {\n if (Iterable.isIterable(state)) return state.toJS();\n else return state;\n};\n\nconst logger = createLogger({\n stateTransformer,\n});\n```\n\n### Transform Immutable (with `combineReducers`)\n```javascript\nconst logger = createLogger({\n stateTransformer: (state) => {\n let newState = {};\n\n for (var i of Object.keys(state)) {\n if (Immutable.Iterable.isIterable(state[i])) {\n newState[i] = state[i].toJS();\n } else {\n newState[i] = state[i];\n }\n };\n\n return newState;\n }\n});\n```\n\n### Log batched actions\nThanks to [@smashercosmo](https://github.com/smashercosmo)\n```javascript\nimport createLogger from 'redux-logger';\n\nconst actionTransformer = action => {\n if (action.type === 'BATCHING_REDUCER.BATCH') {\n action.payload.type = action.payload.map(next => next.type).join(' => ');\n return action.payload;\n }\n\n return action;\n};\n\nconst level = 'info';\n\nconst logger = {};\n\nfor (const method in console) {\n if (typeof console[method] === 'function') {\n logger[method] = console[method].bind(console);\n }\n}\n\nlogger[level] = function levelFn(...args) {\n const lastArg = args.pop();\n\n if (Array.isArray(lastArg)) {\n return lastArg.forEach(item => {\n console[level].apply(console, [...args, item]);\n });\n }\n\n console[level].apply(console, arguments);\n};\n\nexport default createLogger({\n level,\n actionTransformer,\n logger\n});\n```\n\n## To Do\n- [ ] Update example to [create-react-app](https://github.com/facebookincubator/create-react-app)\n- [ ] Update eslint config to [airbnb's](https://www.npmjs.com/package/eslint-config-airbnb)\n- [ ] Clean up code, because it's very messy, to be honest\n- [ ] Write tests\n- [ ] Node.js support\n- [ ] React-native support\n\nFeel free to create PR for any of those tasks!\n\n## Known issues\n* Performance issues in react-native ([#32](https://github.com/evgenyrodionov/redux-logger/issues/32))\n\n## License\nMIT\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/theaqua/redux-logger.git" }, "scripts": { "build": "npm run build:lib && npm run build:umd && npm run build:umd:min", "build:lib": "$(npm bin)/babel src --out-dir lib", "build:umd": "LIBRARY_NAME=reduxLogger NODE_ENV=development $(npm bin)/webpack src/index.js dist/index.js --config webpack.build.js", "build:umd:min": "LIBRARY_NAME=reduxLogger NODE_ENV=production $(npm bin)/webpack -p src/index.js dist/index.min.js --config webpack.build.js", "clean": "$(npm bin)/rimraf dist lib", "coverage": "nyc report", "coverage:html": "nyc report --reporter=html && (http-server -p 8077 ./coverage & open-url http://localhost:8077/)", "coverage:production": "nyc report --reporter=text-lcov > coverage.lcov && codecov", "lint": "$(npm bin)/eslint src", "precommit": "npm run test", "spec": "NODE_PATH=src nyc --all --silent --require babel-core/register mocha --plugins transform-inline-environment-variables --recursive spec/*.spec.js", "spec:watch": "NODE_ENV=development npm run spec -- --watch", "test": "NODE_ENV=development npm run lint && npm run spec", "test:production": "NODE_ENV=production npm run lint && npm run spec" }, "version": "2.10.2" }