react-native-asoft-logger
TypeScript icon, indicating that this package has built-in type declarations

0.1.46 • Public • Published

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

/react-native-asoft-logger/

    Package Sidebar

    Install

    npm i react-native-asoft-logger

    Weekly Downloads

    89

    Version

    0.1.46

    License

    MIT

    Unpacked Size

    91.9 kB

    Total Files

    45

    Last publish

    Collaborators

    • jedrzej.asoft