diff --git a/circle.yml b/circle.yml index d21cf76..58f69ef 100644 --- a/circle.yml +++ b/circle.yml @@ -6,5 +6,5 @@ test: - mkdir -p $CIRCLE_TEST_REPORTS/unit override: - npm run test:lint - - nvm use 4 && MOCHA_FILE=$CIRCLE_TEST_REPORTS/unit/node4.xml npm run test:unit - - nvm use 6 && MOCHA_FILE=$CIRCLE_TEST_REPORTS/unit/node6.xml npm run test:ci + - nvm use 6 && MOCHA_FILE=$CIRCLE_TEST_REPORTS/unit/node4.xml npm run test:unit + - nvm use 8 && MOCHA_FILE=$CIRCLE_TEST_REPORTS/unit/node6.xml npm run test:ci diff --git a/package.json b/package.json index cde3655..49a296f 100644 --- a/package.json +++ b/package.json @@ -15,17 +15,18 @@ ], "author": "Tim De Pauw (https://tmdpw.eu/)", "engines": { - "node": ">=4" + "node": ">=6" + }, + "peerDependencies": { + "winston": "^2.3.1" }, "dependencies": { "aws-sdk": "^2.58.0", "babel-runtime": "^6.23.0", "bottleneck": "^1.15.1", - "debug": "^2.6.8", - "defaults": "^1.0.3", + "debug": "^3.1.0", "lodash.find": "^4.4.0", - "lodash.isempty": "^4.2.1", - "winston": "^2.3.1" + "lodash.isempty": "^4.2.1" }, "devDependencies": { "babel-cli": "^6.24.1", @@ -34,14 +35,14 @@ "babel-register": "^6.24.1", "chai": "^4.0.2", "chai-as-promised": "^7.0.0", - "coveralls": "^2.13.1", + "coveralls": "^3.0.0", "delay": "^2.0.0", "in-publish": "^2.0.0", - "mocha": "^3.4.2", + "mocha": "^4.0.1", "mocha-junit-reporter": "^1.13.0", "nyc": "^11.0.3", "rimraf": "^2.6.1", - "sinon": "^2.3.1", + "sinon": "^4.1.2", "sinon-chai": "^2.10.0", "standard": "^10.0.2" }, diff --git a/src/cloudwatch-client.js b/src/cloudwatch-client.js index 467fa3d..489fb45 100644 --- a/src/cloudwatch-client.js +++ b/src/cloudwatch-client.js @@ -2,25 +2,26 @@ import _debug from 'debug' import AWS from 'aws-sdk' -import defaults from 'defaults' import find from 'lodash.find' import CloudWatchEventFormatter from './cloudwatch-event-formatter' const debug = _debug('winston-aws-cloudwatch:CloudWatchClient') +const DEFAULT_OPTIONS = { + awsConfig: null, + formatLog: null, + formatLogItem: null, + createLogGroup: false, + createLogStream: false, + submissionRetryCount: 1 +} + export default class CloudWatchClient { constructor (logGroupName, logStreamName, options) { debug('constructor', {logGroupName, logStreamName, options}) this._logGroupName = logGroupName this._logStreamName = logStreamName - this._options = defaults(options, { - awsConfig: null, - formatLog: null, - formatLogItem: null, - createLogGroup: false, - createLogStream: false, - submissionRetryCount: 1 - }) + this._options = Object.assign({}, DEFAULT_OPTIONS, options) this._formatter = new CloudWatchEventFormatter(this._options) this._sequenceToken = null this._client = new AWS.CloudWatchLogs(this._options.awsConfig) diff --git a/src/relay.js b/src/relay.js index 05704a4..ab057a6 100644 --- a/src/relay.js +++ b/src/relay.js @@ -2,21 +2,22 @@ import _debug from 'debug' import Bottleneck from 'bottleneck' -import defaults from 'defaults' import Queue from './queue' import {EventEmitter} from 'events' const debug = _debug('winston-aws-cloudwatch:Relay') +const DEFAULT_OPTIONS = { + submissionInterval: 2000, + batchSize: 20 +} + export default class Relay extends EventEmitter { constructor (client, options) { super() debug('constructor', {client, options}) this._client = client - this._options = defaults(options, { - submissionInterval: 2000, - batchSize: 20 - }) + this._options = Object.assign({}, DEFAULT_OPTIONS, options) this._limiter = null this._queue = null } diff --git a/test/unit/cloudwatch-client.spec.js b/test/unit/cloudwatch-client.spec.js index 23e6f1c..9b942bc 100644 --- a/test/unit/cloudwatch-client.spec.js +++ b/test/unit/cloudwatch-client.spec.js @@ -1,6 +1,5 @@ 'use strict' -import defaults from 'defaults' import CloudWatchClient from '../../src/cloudwatch-client' import LogItem from '../../src/log-item' @@ -50,13 +49,13 @@ const streamsStrategies = { } const createClient = (options) => { - options = defaults(options, { + options = Object.assign({ clientOptions: null, streamsStrategy: streamsStrategies.default, groupErrorCode: null, streamErrorCode: false, putRejectionCode: null - }) + }, options) const client = new CloudWatchClient(logGroupName, logStreamName, options.clientOptions) let putPromise