mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2025-12-23 22:18:36 -05:00
37 lines
733 B
JavaScript
37 lines
733 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 = {
|
|
// eslint-disable-next-line no-undef
|
|
severity: __DEV__
|
|
? "debug"
|
|
: "info",
|
|
transport,
|
|
transportOptions: {
|
|
FS: RNFS,
|
|
fileName
|
|
}
|
|
};
|
|
|
|
const log = logger.createLogger( config );
|
|
|
|
export {
|
|
log,
|
|
logFilePath
|
|
};
|