Skip to content

Commit

Permalink
fix: #230
Browse files Browse the repository at this point in the history
  • Loading branch information
imevro committed May 17, 2017
1 parent db841f3 commit ab1fe78
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-logger",
"version": "3.0.4",
"version": "3.0.5",
"description": "Logger for Redux",
"main": "dist/redux-logger.js",
"module": "src/index.js",
Expand Down Expand Up @@ -64,7 +64,6 @@
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-inline-environment-variables": "6.8.0",
"babel-preset-es2015": "^6.24.0",
"babel-preset-stage-0": "^6.22.0",
"chai": "3.5.0",
"codecov": "1.0.1",
"eslint": "^3.19.0",
Expand Down
36 changes: 15 additions & 21 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ function printBuffer(buffer, options) {
// Render
try {
if (isCollapsed) {
if (colors.title && isUsingDefaultFormatter) { logger.groupCollapsed(`%c ${title}`, ...headerCSS); } else logger.groupCollapsed(title);
if (colors.title && isUsingDefaultFormatter) {
logger.groupCollapsed(`%c ${title}`, ...headerCSS);
} else logger.groupCollapsed(title);
} else if (colors.title && isUsingDefaultFormatter) {
logger.group(`%c ${title}`, ...headerCSS);
} else {
Expand All @@ -93,41 +95,33 @@ function printBuffer(buffer, options) {

if (prevStateLevel) {
if (colors.prevState) {
logger[prevStateLevel](
'%c prev state',
`color: ${colors.prevState(prevState)}; font-weight: bold`,
prevState,
);
const styles = `color: ${colors.prevState(prevState)}; font-weight: bold`;

logger[prevStateLevel]('%c prev state', styles, prevState);
} else logger[prevStateLevel]('prev state', prevState);
}

if (actionLevel) {
if (colors.action) {
logger[actionLevel](
'%c action ',
`color: ${colors.action(formattedAction)}; font-weight: bold`,
formattedAction,
);
const styles = `color: ${colors.action(formattedAction)}; font-weight: bold`;

logger[actionLevel]('%c action ', styles, formattedAction);
} else logger[actionLevel]('action ', formattedAction);
}

if (error && errorLevel) {
if (colors.error) {
logger[errorLevel](
'%c error ',
`color: ${colors.error(error, prevState)}; font-weight: bold;`,
error,
);
const styles = `color: ${colors.error(error, prevState)}; font-weight: bold;`;

logger[errorLevel]('%c error ', styles, error);
} else logger[errorLevel]('error ', error);
}

if (nextStateLevel) {
if (colors.nextState) {
logger[nextStateLevel](
'%c next state',
`color: ${colors.nextState(nextState)}; font-weight: bold`,
nextState,
);
const styles = `color: ${colors.nextState(nextState)}; font-weight: bold`;

logger[nextStateLevel]('%c next state', styles, nextState);
} else logger[nextStateLevel]('next state', nextState);
}

Expand Down

0 comments on commit ab1fe78

Please sign in to comment.