react-native-asoft-logger

Asoft logger

Usage no npm install needed!

<script type="module">
  import reactNativeAsoftLogger from 'https://cdn.skypack.dev/react-native-asoft-logger';
</script>

README

react-native-asoft-logger

Asoft logger

Installation

npm install react-native-asoft-logger --save
npm install react-native-fs --save
npm install rn-fetch-blob --save

Example usage without logs upload feature

import RNFS from 'react-native-fs';
import AL from 'react-native-asoft-logger';
import { AsoftLoggerConfig } from 'react-native-asoft-logger/lib/typescript/src/AsoftLogger';
import moment from 'moment';

const logFileSchemaDefault: string = 'gss-audit-logs-';
const gssLoggerConfig : AsoftLoggerConfig = {
  logFileSchema: logFileSchemaDefault,
  logFileName: `${logFileSchemaDefault}${moment().format('YYYY-MM-DD').toString()}`,
  internalLogsPath: `${RNFS.DocumentDirectoryPath}/asoft/gss`,
  externalLogsPath: `${RNFS.ExternalStorageDirectoryPath}/asoft/gss`,
}

const gssLogger = new AL.AsoftLogger(gssLoggerConfig);
const externalLogsPath = gssLogger.getExternalLogsPath();
export default gssLogger;

export { externalLogsPath };

Example usage with logs upload feature

import http from './httpService';
import RNFS from 'react-native-fs';
import AL from 'react-native-asoft-logger';
import Endpoint from './endpoints';
import { AsoftLoggerConfig } from 'react-native-asoft-logger/lib/typescript/src/AsoftLogger';
import moment from 'moment';

const logFileSchemaDefault: string = 'gsc-audit-logs-';
const trustLoggerConfig : AsoftLoggerConfig = {
  logFileSchema: logFileSchemaDefault,
  logFileName: `${logFileSchemaDefault}${moment().format('YYYY-MM-DD').toString()}`,
  internalLogsPath: `${RNFS.DocumentDirectoryPath}/asoft/gsc`,
  externalLogsPath: `${RNFS.ExternalStorageDirectoryPath}/asoft/gsc`,
}

const trustLogger = new AL.AsoftLogger(trustLoggerConfig).withUpload(http, Endpoint.Storage.GetSasTokenForAuditLogs);
const externalLogsPath = trustLogger.getExternalLogsPath();
const httpInstance = trustLogger.getHttpInstace();
const sasTokenEndpoint = trustLogger.getSasTokenEndpoint();
export default trustLogger;

export { externalLogsPath, httpInstance, sasTokenEndpoint };

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT