MohGovIL/hamagen-react-native

Remove/Avoid console.log calls in release build

Opened this issue · 1 comments

There are several console.log calls in the code below:

it's better to remove/avoid them in release build, so they will run only in debug builds, if the messages are needed for later retrieval it's better use other mechanism which are built for this purpose (collecting logs/errors)

console.log('Background fetch event fired');

console.log('BackgroundGeolocation is configured and ready: ', state.enabled);

console.log('react-native-background-geolocation - Start success');

console.log('isIgnoring', isIgnoring);

console.log('payload', payload);

console.log('[BackgroundFetch HeadlessTask] start: ', taskId);

console.log('[BackgroundGeolocation HeadlessTask] -', event.name);

console.log('Cannot get current SSID!', e);

console.log('Cannot get current SSID!', e);

console.log('data message received');

console.log(error);

console.log('migrateTable error:', error);

console.log('Could not find data');

console.log('Could not find data');

new IntersectionSickDatabase().updateSickRecord(exposures[index]).catch(console.log);

You can add this code to App.tsx

useEffect(() => {
    StatusBar.setBarStyle('dark-content');

    Linking.addEventListener('url', (data) => {
      navigationRef.current && onOpenedFromDeepLink(data.url, navigationRef.current);
    });

    // Add the following
    if (!__DEV__) {
      console.disableYellowBox = true;
      // disable console. log in production
      console.log = () => { };
      console.info = () =>  { };
      console.warn = () =>  { };
      console.error = () =>  { };
      console.debug = () =>  { };
    }
  }, []);