Skip to content

low-ghost/redux-node-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Redux-Node-Logger

A Redux logger for node environments

redux-node-logger screenshot

Install

npm install --sav-dev redux-node-logger

The Gist

No innovations here, just a logger middleware for redux that will write all redux actions and state changes to the node console. Entirely based on redux-logger

Usage

redux-node-logger must be called as a function before being utilized as middleware. This allows passing in options to overwrite all colors and arrow icons, as well as a predicate that functions like that in redux-logger. Here's what a simple configureStore function might look like

function configureStore() {
  //other conditions like client etc
  } else if (SERVER && DEVELOPMENT) {

    const createNodeLogger = require('redux-node-logger');
    finalCreateStore = compose(
      applyMiddleware(promiseMiddleware, createNodeLogger({/* an options object */})),
      createStore
    );

  }

  return finalCreateStore(rootReducer);
}

Options Object

The option object has overridable defaults that look like this:

  {
    downArrow: '▼',
    rightArrow: '▶',
    messageColor: 'bright-yellow',
    prevColor: 'grey',
    actionColor: 'bright-blue',
    nextColor: 'green',
    predicate: ''
  }

###immutable works fine because it converts to POJO on JSON.stringify

###Source uses renderkid to output color and formatting. Doesn't seem to support JSON.stringify(obj, null, 4) for instance. Anyhow, not much to it really. Feel free to look in on createNodeLogger.js and build something more to your needs

###Webpack you might need to add

plugins: [
  new webpack.IgnorePlugin(/renderkid/),
]

to your config

About

A Redux Logger for Node Environments

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published