mowispace / react-native-logs

Performance-aware simple logger for React-Native and Expo with namespaces, custom levels and custom transports (colored console, file writing, etc.)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any reason why logType isn't exported?

radiodario opened this issue · comments

I'm writing a class with its own custom logger instance and using typescript I can't make a logger instance a typed property / member of the class correctly - since logTyped isn't exported:

import RNFS from 'react-native-fs';
import { logger } from 'react-native-logs';

export default class CallLoger {
  loggerInstance: logTyped;

  constructor(props) {
    // ...
  }

  initialise(callId, userId) {
    this.loggerInstance = logger.createLogger({
       // ...
    });
  }
}

Typescript complains here - Am I using the wrong approach? I want to have a long lived class that initialises a logger which writes to a new file each time, but that is initialised several times during the app's lifecycle

Thanks!

answered my own question:

import { logger } from 'react-native-logs';

// ...

loggerInstance: ReturnType<typeof logger.createLogger>