Skip to content

Commit

Permalink
Require Node 6; drop defaults dependency; make winston a peer dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
timdp committed Dec 3, 2017
1 parent cd379c2 commit 8df121d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
4 changes: 2 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
],
"author": "Tim De Pauw <hi@tmdpw.eu> (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",
Expand All @@ -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"
},
Expand Down
19 changes: 10 additions & 9 deletions src/cloudwatch-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 6 additions & 5 deletions src/relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 2 additions & 3 deletions test/unit/cloudwatch-client.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

import defaults from 'defaults'
import CloudWatchClient from '../../src/cloudwatch-client'
import LogItem from '../../src/log-item'

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8df121d

Please sign in to comment.