2.0.0 • Published 5 years ago
@fooxly/loggern v2.0.0
:page_facing_up: LoggerN
Logger for changes in the ReactN global state. Supported out of the box by PersistN.
A package by Fooxly, based on redux-logger.
:rocket: Recent Changes
- Added support for ReactN 2.x
- Performance improvements
- Removed PersistN & RequestN support (read next change)
- Added support for actionTransforms (supported by PersistN 2.x)
- Now logging names of reducers responsible for state changes
:cloud: Installation
using npm
npm install --save @fooxly/loggern
using yarn
yarn add @fooxly/loggern
:paperclip: Importing
ES6 and up
The module uses an ES6 style export statement, simply use import
to load the module.
import logger from '@fooxly/loggern';
ES5
If you're using an ES5 require statement to load the module, please add default
. Look here for more details.
Note: The remaining documentation is written in ES6.
var logger = require('@fooxly/loggern').default;
:triangular_ruler: Usage
Make sure to add the logger callback before setting your global state!
Example File: index.js
import { setGlobal, addCallback } from 'reactn'
import logger from '@fooxly/loggern'
addCallback(logger())
setGlobal({
foo: 'bar'
})
Action Transforms
Note: This part of the documentation is incomplete
addCallback(logger({
actionTransforms: (nextState, diff, prevState => {
return { key: 'bar', label: 'foo', stateOnly: true }
})
}))
:closed_book: API
Note: This part of the documentation is incomplete
import logger, { defaultStyles } from '@fooxly/loggern'
logger({
groups: true, // Boolean
noDiff: false, // Boolean
timestamp: true, // Boolean
logInitial: true, // Boolean
logger: console, // Logger Object
styles: defaultStyles, // Styles Object (see styles.js)
level: 'log', // String ('log' | 'warn' | 'error' | 'info' | 'debug')
collapsed: (nextState, diff, prevState) => true, // Boolean | Function
actionTransforms: (nextState, diff, prevState) => ({ key, label, stateOnly }) // Function | [Function]
})
:clipboard: To-do
predicate
option, to determine whether or not to log a differencediffTransformer
option, transform the difference before print (eg. convert Immutable object to JS object)stateTransformer
option, transform the state before print (eg. convert Immutable object to JS object)- Log keys of changes in nested object instead of root (eg.
{ foo: { bar: 'test' } }
asfoo.bar
instead offoo
)
:heart: Support our projects
You can support us by donating through BuyMeACoffee or PayPal.