1.0.0 • Published 6 years ago

amnis-logger v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

This package uses redux-logger for it's entire functionality. The only difference being the way you attach it: redux-logger is attached as middleware and amnis doesn't have the concept of middleware, so you attach the logger onto your root reducer.

🔧 Installation

Assuming you use npm as your package manager:

npm install --save amnis-logger

UMD build:

<script type="application/javascript" src="https://unpkg.com/amnis-logger"></script>

Refer to the examples section at the bottom to see the UMD build in action.

Usage

Since amnis doesn't have the concept of middleware, you attach the logger directly onto your root reducer:

import {createStore} from 'amnis'  
import {withLogging} from 'amnis-logger'
import {rootReducer} from './reducers'
  
const store = createStore(withLogging(reducer, {collapsed: true}))

You can configured the logger by passing in the options parameter as the seconds argument. Please refer to redux-logger's documentation for the list of available options.

const loggerOptions = {
  collapsed: true,
  diff: false
}
const store = createStore(withLogging(reducer, loggerOptions))
Logging only in development
import {createStore} from 'amnis'  
import {withLogging} from 'amnis-logger'
import {rootReducer} from './reducers'

if  (process.env.NODE_ENV  ===  `development`)  {
  rootReducer = require('amnis-logger').withLogging(rootReducer)
}
  
const store = createStore(rootReducer)

📓 Examples

You can see a basic example in this jsFiddle.

🍻 License

MIT