npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

effector-logger

v0.15.0

Published

Pretty logger for stores, events, effects and domains.

Downloads

27,176

Readme

Effector Logger

Pretty logger for stores, events, effects and domains.

All Contributors

| Chrome-DevTools-Console | | ---------------------------------------------------------------- | | Chrome-DevTools-Console-Dark |

Installation

npm add effector
npm add --dev effector-logger

or yarn

yarn add effector
yarn add -D effector-logger

Note: effector-logger requires effector to be installed

Usage

Prepare metadata

To make logs more useful we need additional metadata (like names, locations in the code, etc), which is provided by one of the effector plugins.

Babel-plugin

Babel-plugin is built-in in the effector package.

Just add it to your babel configuration.

{
  "plugins": ["effector/babel-plugin"]
}

It is also useful to enable loc generation for dev environment, to see for exact locations of units in the code.

{
  "plugins": [["effector/babel-plugin", { "addLoc": true }]]
}

Read the docs

SWC Plugin

Read effector SWC plugin documentation

Start logging

Just call attachLogger in your entrypoint module.

NOTE: To "see" the createStore, createEvent, etc calls effector-logger needs to be imported at the very top of your entrypoint module. This way initial states of stores will be properly logged at the moment of attachLogger call.

Update logs are not affected by import order.

// src/index.tsx
import { attachLogger } from 'effector-logger';

import React from 'react';
import { createRoot } from 'react-dom/client';
import { App } from './app';
import { appStarted } from './shared/app-events';

attachLogger();

appStarted();

createRoot(document.querySelector('#app')).render(<App />);

After that you will see the logs in your console.

With Scope

If your app uses scope (e.g. you have Server-Side-Rendering) - you will need to pass it to the logger to work.

attachLogger({ scope });

Updates related to provided scope will be prefixed with scope id.

Name

There optional name prefix to the logs. It can be useful if there are few instances of your app, which are using different scopes or if you just want prefix that is better than boring scope id.

attachLogger({
  scope,
  name: `my-cool-app-${appId}`, // all logs will be prefixed with this string
});

Stop logs

To stop logs just call unsubscribe function.

const unlogger = attachLogger();

unlogger();

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' });

Force any unit to be logged

By default only non-derived units are logged. If you want to force some unit to be logged, use configure enabled

import { createEvent } from 'effector';
import { configure } from 'effector-logger';
import { $data, loadDataFx } from './model';

const pageMounted = createEvent<number>();

const mappedMounted = pageMounter.map((x) => x);

configure(mappedMounted, { log: 'enabled' });

// You can pass multiple units as array
configure([$data, loadDataFx], { log: 'enabled' });

Redux DevTools support

Redux DevTools is moved to a different package.

See the @effector/redux-devtools-adapter

Contributors ✨

Thanks go to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

Release process

  1. Check out the draft release.
  2. All PRs should have correct labels and useful titles. You can review available labels here.
  3. Update labels for PRs and titles, next manually run the release drafter action to regenerate the draft release.
  4. Review the new version and press "Publish"
  5. If required check "Create discussion for this release"