Sync or Async Aware logger for react-native
This Project address couple of issues
- Simple to use
- Group logs
- Filter Logs by name
- Async aware
npm install react-native-logger --saveyarn add react-native-loggerimport { logger } from 'react-native-logger'There are 3 functions.
similar to console.log. for example
logger.log('this is awesome', 10, 10)
// logs as
// this is awesome 10 10it accepts 3 arguments. name is an identifier which you can use in setFilters. title is a simple description about the log it self. and log is a function which your loggin happening. The signiture of LogFn is
type LogFn: (log: (...args: Array<any>) => void) => void | Promise<any>It basically group related logs into one. also you can return a promise which cause the logs waits until you tell it so.
logger.group('api', 'loads users list', async (log) => {
const users = await apis.getAllUsers();
log('list of users', users);
actions.updateUsersList(users);
});simply filters out everything except those names that you pass to logs. to clear the filter simply call it without arguments.
logger.filters('api')cheers,