Skip to content

weiying-shenzhen/freactal-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logger for freactal

Table of contents

Install

npm i --save freactal-logger

Usage

In freactal mddleware is defined per state container, so you should create logger for per state container.

import { provideState } from 'freactal';
import createLogger from 'freactal-logger';

const logger = createLogger({
  // ...options
});

provideState({
  middleware: [logger],
});

Options

{
  collapsed, // the log group is collapsed or not.
}

Options description

collapsed (Boolean)

Takes a boolean to inidicate the log group should be collapsed or not.

Default: false

Recipes

Log only in development

import { provideState } from 'freactal';
import createLogger from 'freactal-logger';


const middlewares = [];

if (process.env.NODE_ENV === `development`) {
  const logger = createLogger();
  middlewares.push(logger);
}

provideState({
  middleware: middlewares,
});

To Do

  • Write tests
  • Support more options

Feel free to create PR for any of those tasks!

License

MIT