Merge pull request #24480 from clementallen/master

[sumo-logger] - Added methods and config options from new version
This commit is contained in:
Mine Starks
2018-03-23 13:42:20 -07:00
committed by GitHub
2 changed files with 26 additions and 4 deletions
+22 -1
View File
@@ -1,6 +1,7 @@
// Type definitions for js-logging-sdk 1.0
// Type definitions for js-logging-sdk 1.3
// Project: https://github.com/SumoLogic/js-logging-sdk
// Definitions by: forabi <https://github.com/forabi>
// clementallen <https://github.com/clementallen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -67,6 +68,11 @@ declare namespace SumoLogger {
* This value sets the Source Name for the logged message.
*/
sourceName?: string;
/**
* This value enabled and disables sending data as graphite metrics
*/
graphite?: boolean;
}
interface PerMessageOptions {
@@ -124,6 +130,21 @@ declare class SumoLogger {
* messages are sent to Sumo Logic.
*/
flushLogs(): void;
/**
* Stop sending batched logs
*/
stopLogSending(): void;
/**
* Start sending batched logs at the preconfigured interval
*/
startLogSending(): void;
/**
* Empty the current queue of logs
*/
emptyLogQueue(): void;
}
export = SumoLogger;
+4 -3
View File
@@ -6,14 +6,15 @@ const onSuccessSpy = expect.createSpy();
const logger = new SumoLogger({
endpoint: 'http://example.com/',
onSuccess() {
console.log('success');
},
onSuccess: onSuccessSpy,
onError: onErrorSpy,
});
expect(logger.flushLogs).toExist();
expect(logger.log).toExist();
expect(logger.emptyLogQueue).toExist();
expect(logger.startLogSending).toExist();
expect(logger.stopLogSending).toExist();
logger.log('message');
logger.log({ json: 'object' });