apollo-link-logger
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,1 +0,1 @@ | ||
{"name":"apollo-link-logger","version":"1.0.2","description":"Logger for Apollo Link that uses a similar format to redux-logger. Includes performance information.","author":"Adrian Perez adrian@adrianperez.org","main":"src/index.js","engines":{"node":"> 4","npm":"> 3"},"scripts":{"start":"webpack","commit":"commit","precommit":"lint-staged","commitmsg":"commitlint -e $GIT_PARAMS","flow":"flow","lint":"eslint","add-contributor":"all-contributors add","generate-contributors":"all-contributors generate","build":"exit 0","test":"jest","prettier:js":"prettier --write --trailing-comma all --tab-width 2 --single-quote --parser flow --print-width 80 \"src/**/*.js\" \"!**/dist/**\"","semantic-release":"semantic-release pre && npm publish && semantic-release post"},"lint-staged":{"*.js":["prettier --write --trailing-comma all --tab-width 2 --single-quote --parser flow --print-width 80","git add","jest --bail --findRelatedTests"]},"config":{"commitzen":{"path":"@commitlint/prompt"}},"jest":{"collectCoverageFrom":["src/**/*.js","!**/node_modules/**","!**/vendor/**"]},"quokka":{"babel":true},"devDependencies":{"@commitlint/cli":"^4.2.2","@commitlint/config-angular":"^3.1.1","all-contributors-cli":"^4.6.0","babel-eslint":"^7.2.3","babel-preset-env":"^1.6.0","babel-jest":"21.0.0","commitizen":"^2.9.6","eslint":"^4.6.1","eslint-config-airbnb-base":"^12.1.0","eslint-config-prettier":"^2.4.0","eslint-plugin-flowtype":"^2.35.1","eslint-plugin-fp":"^2.3.0","eslint-plugin-import":"^2.7.0","eslint-plugin-jest":"^21.0.0","eslint-plugin-prettier":"^2.2.0","flow-bin":"^0.58.0","husky":"^0.14.3","jest":"^21.2.1","lint-staged":"^4.1.3","prettier":"^1.8.1","semantic-release":"^8.2.0"},"peerDependendices":{"apollo-link":"^1.0.0"},"repository":{"type":"git","url":"https://github.com/blackxored/apollo-link-logger.git"}} | ||
{"name":"apollo-link-logger","version":"1.0.3","description":"Logger for Apollo Link that uses a similar format to redux-logger. Includes performance information.","author":"Adrian Perez adrian@adrianperez.org","main":"src/index.js","engines":{"node":"> 4","npm":"> 3"},"scripts":{"start":"webpack","commit":"commit","precommit":"lint-staged","commitmsg":"commitlint -e $GIT_PARAMS","flow":"flow","lint":"eslint","add-contributor":"all-contributors add","generate-contributors":"all-contributors generate","build":"exit 0","test":"jest","prettier:js":"prettier --write --trailing-comma all --tab-width 2 --single-quote --parser flow --print-width 80 \"src/**/*.js\" \"!**/dist/**\"","semantic-release":"semantic-release pre && npm publish && semantic-release post"},"lint-staged":{"*.js":["prettier --write --trailing-comma all --tab-width 2 --single-quote --parser flow --print-width 80","git add","jest --bail --findRelatedTests"]},"config":{"commitzen":{"path":"@commitlint/prompt"}},"jest":{"collectCoverageFrom":["src/**/*.js","!**/node_modules/**","!**/vendor/**"]},"quokka":{"babel":true},"devDependencies":{"@commitlint/cli":"^4.2.2","@commitlint/config-angular":"^3.1.1","all-contributors-cli":"^4.6.0","babel-eslint":"^7.2.3","babel-preset-env":"^1.6.0","babel-jest":"21.0.0","commitizen":"^2.9.6","eslint":"^4.6.1","eslint-config-airbnb-base":"^12.1.0","eslint-config-prettier":"^2.4.0","eslint-plugin-flowtype":"^2.35.1","eslint-plugin-fp":"^2.3.0","eslint-plugin-import":"^2.7.0","eslint-plugin-jest":"^21.0.0","eslint-plugin-prettier":"^2.2.0","flow-bin":"^0.58.0","husky":"^0.14.3","jest":"^21.2.1","lint-staged":"^4.1.3","prettier":"^1.8.1","semantic-release":"^8.2.0"},"peerDependencies":{"apollo-link":"^1.0.0"},"repository":{"type":"git","url":"https://github.com/blackxored/apollo-link-logger.git"}} |
const { ApolloLink } = require('apollo-link'); | ||
const formatMessage = require('./formatMessage'); | ||
const formatMessage = (operationType, operation, ellapsed) => { | ||
const headerCss = [ | ||
'color: gray; font-weight: lighter', // title | ||
`color: ${operationType === 'query' ? '#03A9F4' : 'red'};`, // operationType | ||
'color: #000;', // operationName | ||
'color: gray; font-weight: lighter;', // time, etc | ||
]; | ||
const parts = ['%c apollo']; | ||
parts.push(`%c${operationType}`); | ||
parts.push(`%c${operation.operationName}`); | ||
parts.push(`%c(in ${ellapsed} ms)`); | ||
return [parts.join(' ', ...headerCss)]; | ||
}; | ||
const loggerLink = new ApolloLink((operation, forward) => { | ||
@@ -21,0 +5,0 @@ const startTime = new Date().getTime(); |
398193
23
106
1