mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2025-12-23 22:18:36 -05:00
Removes intentional Realm file deletion to avoid unintentional Realm file deletion, though the latter remains something of a mystery. * Configure Realm with the full path to the file * Remove all Realm.open calls in AuthenticationService in favor of passing the context/provider copy of realm (only one realm instance) * Only delete the realm file on sign out if deleting realm contents fails for some reason * Replaced deleteRealm with semantically more accurate clearRealm Closes #373
33 lines
646 B
JavaScript
33 lines
646 B
JavaScript
import RNFS from "react-native-fs";
|
|
import {
|
|
consoleTransport,
|
|
fileAsyncTransport,
|
|
logger
|
|
} from "react-native-logs";
|
|
|
|
const fileName = "inaturalist-rn-log.txt";
|
|
const logFilePath = `${RNFS.DocumentDirectoryPath}/${fileName}`;
|
|
|
|
// Configure without transport for test. If you want to write output during
|
|
// tests, use console.log
|
|
const transport = [];
|
|
if ( process?.env?.NODE_ENV !== "test" ) {
|
|
transport.push( consoleTransport );
|
|
transport.push( fileAsyncTransport );
|
|
}
|
|
|
|
const config = {
|
|
transport,
|
|
transportOptions: {
|
|
FS: RNFS,
|
|
fileName
|
|
}
|
|
};
|
|
|
|
const log = logger.createLogger( config );
|
|
|
|
export {
|
|
log,
|
|
logFilePath
|
|
};
|