winston-cloudwatch
Advanced tools
Comparing version
@@ -0,1 +1,5 @@ | ||
### 1.11.2 | ||
Increased coverage | ||
### 1.11.1 | ||
@@ -2,0 +6,0 @@ |
@@ -63,3 +63,3 @@ var LIMITS = { | ||
debug('InvalidSequenceTokenException, retrying', true) | ||
submitWithAnotherToken(aws, groupName, streamName, payload, cb) | ||
lib.submitWithAnotherToken(aws, groupName, streamName, payload, cb) | ||
} else { | ||
@@ -77,3 +77,3 @@ debug('error during putLogEvents', err, true) | ||
function submitWithAnotherToken(aws, groupName, streamName, payload, cb) { | ||
lib.submitWithAnotherToken = function(aws, groupName, streamName, payload, cb) { | ||
lib.getToken(aws, groupName, streamName, function(err, token) { | ||
@@ -80,0 +80,0 @@ payload.sequenceToken = token; |
{ | ||
"name": "winston-cloudwatch", | ||
"version": "1.11.1", | ||
"version": "1.11.2", | ||
"description": "Send logs to Amazon Cloudwatch using Winston.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -1,2 +0,2 @@ | ||
# winston-cloudwatch [v1.11.1](https://github.com/lazywithclass/winston-cloudwatch/blob/master/CHANGELOG.md#1111) | ||
# winston-cloudwatch [v1.11.2](https://github.com/lazywithclass/winston-cloudwatch/blob/master/CHANGELOG.md#1112) | ||
@@ -3,0 +3,0 @@ [](https://travis-ci.org/lazywithclass/winston-cloudwatch) [](https://coveralls.io/github/lazywithclass/winston-cloudwatch?branch=master) [](https://david-dm.org/lazywithclass/winston-cloudwatch) [](https://david-dm.org/lazywithclass/winston-cloudwatch#info=devDependencies) [](https://david-dm.org/lazywithclass/winston-cloudwatch#info=peerDependencies) |
@@ -16,2 +16,3 @@ describe('cloudwatch-integration', function() { | ||
sinon.stub(lib, 'getToken').yields(null, 'token'); | ||
sinon.stub(lib, 'submitWithAnotherToken').yields(); | ||
sinon.stub(console, 'error'); | ||
@@ -22,2 +23,3 @@ }); | ||
lib.getToken.restore(); | ||
lib.submitWithAnotherToken.restore(); | ||
console.error.restore(); | ||
@@ -76,4 +78,2 @@ }); | ||
it('puts log events', function(done) { | ||
@@ -123,3 +123,10 @@ lib.upload(aws, 'group', 'stream', Array(20), function() { | ||
}); | ||
}); | ||
it('gets another token if InvalidSequenceTokenException', function(done) { | ||
aws.putLogEvents.yields({ code: 'InvalidSequenceTokenException' }); | ||
lib.upload(aws, 'group', 'stream', Array(20), function(err) { | ||
lib.submitWithAnotherToken.calledOnce.should.equal(true); | ||
done(); | ||
}); | ||
}); | ||
@@ -382,2 +389,27 @@ | ||
describe('submitWithAnotherToken', function() { | ||
var aws = {}; | ||
beforeEach(function() { | ||
aws.putLogEvents = sinon.stub().yields(); | ||
sinon.stub(lib, 'getToken').yields(null, 'new-token'); | ||
sinon.stub(console, 'error'); | ||
}); | ||
afterEach(function() { | ||
lib.getToken.restore(); | ||
console.error.restore(); | ||
}); | ||
it('gets a token then resubmits', function(done) { | ||
lib.submitWithAnotherToken(aws, 'group', 'stream', {}, function() { | ||
aws.putLogEvents.calledOnce.should.equal(true); | ||
aws.putLogEvents.args[0][0].sequenceToken.should.equal('new-token'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -1,2 +0,2 @@ | ||
describe('cloudwatch-integration', function() { | ||
describe('index', function() { | ||
@@ -14,2 +14,5 @@ var sinon = require('sinon'), | ||
this.fakeOptions = options; | ||
}, | ||
config: { | ||
update: sinon.stub() | ||
} | ||
@@ -28,5 +31,10 @@ }; | ||
before(function() { | ||
mockery.enable(); | ||
mockery.enable({ | ||
warnOnReplace: false | ||
}); | ||
mockery.registerAllowable('util'); | ||
mockery.registerAllowable('lodash'); | ||
mockery.registerAllowable('./lib/utils'); | ||
mockery.registerMock('proxy-agent', function() { return 'fake' }); | ||
mockery.registerMock('winston', stubbedWinston); | ||
@@ -68,2 +76,14 @@ mockery.registerMock('aws-sdk', stubbedAWS); | ||
it('configures httpOptions if a proxyServer has been defined', function() { | ||
var options = { | ||
awsOptions: { | ||
region: 'us-east-1' | ||
}, | ||
proxyServer: 'http://test.com' | ||
}; | ||
var transport = new WinstonCloudWatch(options); | ||
stubbedAWS.config.update.calledOnce.should.equal(true); | ||
stubbedAWS.config.update.args[0][0].httpOptions.agent.should.equal('fake'); | ||
}); | ||
}); | ||
@@ -73,3 +93,5 @@ | ||
before(function(done) { | ||
var transport; | ||
beforeEach(function(done) { | ||
transport = new WinstonCloudWatch({}); | ||
@@ -87,2 +109,13 @@ transport.log('level', null, {key: 'value'}, function() { | ||
it('flushes logs and exits in case of an exception', function(done) { | ||
transport = new WinstonCloudWatch({}); | ||
transport.log('level', 'uncaughtException: ', {}, function() { | ||
clock.tick(2000); | ||
should.not.exist(transport.intervalId); | ||
// if done is called it means submit(callback) has been called | ||
done(); | ||
}); | ||
}); | ||
describe('as json', function() { | ||
@@ -186,3 +219,2 @@ | ||
}; | ||
mockery.registerMock('./lib/cloudwatch-integration', stubbedCloudwatchIntegration); | ||
console.error.restore(); | ||
@@ -189,0 +221,0 @@ }); |
Sorry, the diff of this file is not supported yet
46513
4.63%21
5%990
6%