logger
logger copied to clipboard
Simple logger with stores inspector
Effector Logger
Pretty logger for stores, events, effects and domains.
![]() |
|---|
![]() |
Installation
npm install effector
npm install --dev effector-logger
or yarn
yarn add effector
yarn add -D effector-logger
Note: effector-logger requires
effectorto be installed
Usage
Add babel plugin to your babel.config.js or .babelrc file
{
"plugins": ["effector-logger/babel-plugin"]
}
Options
Babel plugin has few configuration options:
inspector: boolean- enables or disableseffector-inspector. Default:falseeffector: EffectorBabelPluginOptions- overrides for underlyingeffector/babel-plugin. Default:{}
Config example:
{
"plugins": [
[
"effector-logger/babel-plugin",
{
"inspector": true,
"effector": {
"reactSsr": true,
"factories": ["shared/lib/effector-timer", "effector-forms"]
}
}
]
]
}
Create React App and macros support
Just use effector-logger/macro:
import { createStore, createEvent } from 'effector-logger/macro';
Debug some modules
- Open a module (js/ts/esm file) you need to debug
Replace import from "effector" to "effector-logger"
For example:
- import { Event, Store, createEvent, forward } from "effector"
+ import { Event, Store, createEvent, forward } from "effector-logger"
- Open DevTools Console, use "Filter" to show only required logs
Debug domain with settings
- Open a module with domain
import { attachLogger } from 'effector-logger/attach'- Attach logger to your domain
Example:
import { createDomain } from 'effector';
import { attachLogger } from 'effector-logger/attach';
export const myDomain = createDomain('my');
attachLogger(myDomain);
Settings available only on attachLogger
Second argument is an object { reduxDevtools, console, inspector }, each field is optional can be "enabled" or "disabled".
If field is not provided it is "enabled" by default.
reduxDevtoolsif"disabled"do not send updates to redux devtools extensioninspectorif"disabled"do not send updates to effector inspectorconsoleif"disabled"do not log updates toconsole.login browser devtools
// disable all logs
attachLogger(myDomain, {
reduxDevtools: 'disabled',
inspector: 'disabled',
console: 'disabled',
});
Hide any unit from log
Sometimes it is required to hide some events or stores from log.
It is simple to implement: just call configure on your unit.
import { createEvent } from 'effector'
import { configure } from 'effector-logger'
import { $data, loadDataFx } from './model'
const pageMounted = createEvent<number>();
configure(pageMounted, { log: 'disabled' })
// You can pass multiple units as array
configure([$data, loadDataFx], { log: 'disabled' })
effector-root
Just import root domain and attach:
import { attachLogger } from 'effector-logger/attach';
import { root } from 'effector-root';
attachLogger(root);
Create React App and macros support
import { attachLogger } from 'effector-logger/attach';
import { root } from 'effector-root/macro';
attachLogger(root);
Inspector
Just import effector-logger/inspector in the app.ts and open DevTools Console in browser.
Note: inspector requires browser environment. ReactNative is not supported
import 'effector-logger/inspector';
Then press CTRL+B to open Inspector inside the app.
Redux DevTools support
If you have redux devtools extensions, just open it.
Using in the project with Redux
If you are using [email protected] and lower with effector-logger in the project with redux, then you need to rewrite redux createStore import to createReduxStore and use it.
Otherwise, redux will give you an error: Unexpected keys found in preloadedState argument passed to createStore.
import { createStore as createReduxStore } from 'redux';
const store = createReduxStore();
// reducers
Using logger with SSR
import { attachLogger } from 'effector-logger/attach';
import { root, fork, hydrate } from 'effector-root';
const scope = fork(root);
hydrate(scope, { values: INITIAL_STATE });
attachLogger(scope);
Contributors ✨
Thanks go to these wonderful people (emoji key):
Andrey Antropov 💻 |
Sergey Sova 💻 |
Sozonov 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
Release process
- Check out the draft release.
- All PRs should have correct labels and useful titles. You can review available labels here.
- Update labels for PRs and titles, next manually run the release drafter action to regenerate the draft release.
- Review the new version and press "Publish"
- If required check "Create discussion for this release"

