npm install --save sumologic.js
npm run build
npm run watch
npm run test
You need to import SumoLogic
module:
import SumoLogic from 'sumologic.js';
const settings = {
endpoint: "{your Sumo Logic http endpoint}",
captureConsole: true,
captureError: true,
devMode: false,
};
const sumoLogic = new SumoLogic(settings);
To log an info message
sumoLogic.info({
message: 'message',
any: 'object',
});
To log an error message
sumoLogic.error({
message: 'message',
any: 'object',
});
To log a warning message:
sumoLogic.warn({
message: 'message',
any: 'object',
});
endpoint
(mandatory) provided by SumoLogic when you create an HTTP collection
syncInterval
(optional - 3000ms by default) is the frequency we're sending the logs to SumoLogic.
captureConsole
(optional - true by default). To send console logs to SumoLogic; it includes ('warn', 'info', 'log', 'error').
captureError
(optional - true by default). To send runtime errors to SumoLogic.
devMode
(optional - false by default). To disable sending logs to the server, typically used to disable logging in development mode.
It is possible to attach context to the logs. Here is how to do it:
sumoLogic.context = {
host: http://example.com,
object_id: 22200
};
SumoLogic.dump()
dump all the logs that are not sent yet to SumoLogic. One use case for this is when you need to make sure all the logs are sent before closing your application.