Files
iNaturalistReactNative/react-native-logs.config.js
Johannes Klein 48fcea1526 359 post logs to internal logging (#1256)
* Made react-native-logs post to API log endpoint

* Try to build a slightly more informative user agent

* Made react-native-logs post to API log endpoint

* Try to build a slightly more informative user agent

* Remove unused const

* Replace other usages of exported user agent

* Revert "Remove unused const"

This reverts commit 02389c8390.

* Revert removal of axios instance

* Strange order

* Remove device name from user agent

* Copy logstash transporter to new file and change to post

* Update import

* Remove comma

* Get the user jwt token as authorization for the log request

* Use anonymous token as app token

* Mock away logs config file because it now has a dependency on authentication

* Code style

* Typo

* Add timestamp field to form data, to show client_timestamp on the logs

* Add TODO

* Add a developer button to force a js-side error

* Add comments

---------

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2024-03-07 00:04:29 +01:00

36 lines
692 B
JavaScript

import iNatLogstashTransport from "api/log.ts";
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}`;
const transport = [];
transport.push( consoleTransport );
transport.push( fileAsyncTransport );
transport.push( iNatLogstashTransport );
const config = {
dateFormat: "iso",
// eslint-disable-next-line no-undef
severity: __DEV__
? "debug"
: "info",
transport,
transportOptions: {
FS: RNFS,
fileName
}
};
const log = logger.createLogger( config );
export {
log,
logFilePath
};