Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fileAsyncTransport Error when using it from separate local package #101

Open
partho-maple opened this issue Jul 23, 2024 · 1 comment
Open

Comments

@partho-maple
Copy link

I have created a separate React Native local package, where i put all of my logging related code. Then using this Logger package in the main app. But when i use fileAsyncTransport, i get the a crash with following error,

ERROR : Invariant Violation: `new NativeEventEmitter()` requires a non-null argument., js engine: hermes 

The error message is itself doesn't give much information regarding where to look at and what's wrong. But consoleTransport works perfectly

Following if my code,

import { consoleTransport, logger, fileAsyncTransport } from 'react-native-logs';
import RNFS from "react-native-fs";
import * as FileSystem from 'expo-file-system';


const defaultConfig = {
    levels: {
        debug: 0,
        info: 1,
        warn: 2,
        error: 3,
    },
    severity: __DEV__ ? 'debug' : 'warn',
    transport: fileAsyncTransport,
    // transport: consoleTransport,
    transportOptions: {
        colors: {
            debug: 'green',
            info: 'blueBright',
            warn: 'yellowBright',
            error: 'redBright',
        },
        FS: RNFS,
        // FS: FileSystem,
        fileName: `FeniksLog_{date-today}.txt`,
    },
    async: true,
    dateFormat: 'utc',
    printLevel: true,
    printDate: true,
    fixedExtLvlLength: false,
    enabled: true,
};

const Logger: ReturnType<typeof logger.createLogger> = logger.createLogger(defaultConfig);
Logger.patchConsole();
export { Logger };

Are there any special configuration needed in order to use fileAsyncTransport from a separate local package?

@alessandro-bottamedi
Copy link
Collaborator

You need to install RNFS correctly, and it must be properly linked in your React Native app. I believe the issue lies there...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants