Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit cd05c56

Browse files
authored
(3.0) remove Winston dependency, use SDK's logger (#17)
1 parent ff86964 commit cd05c56

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

dynamodb_feature_store.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
var AWS = require('aws-sdk');
2-
var winston = require('winston');
32

43
var helpers = require('./dynamodb_helpers');
54
var CachingStoreWrapper = require('launchdarkly-node-server-sdk/caching_store_wrapper');
@@ -11,19 +10,17 @@ function DynamoDBFeatureStore(tableName, options) {
1110
if (ttl === null || ttl === undefined) {
1211
ttl = defaultCacheTTLSeconds;
1312
}
14-
return new CachingStoreWrapper(dynamoDBFeatureStoreInternal(tableName, options), ttl, 'DynamoDB');
13+
return config =>
14+
new CachingStoreWrapper(
15+
dynamoDBFeatureStoreInternal(tableName, options, config.logger),
16+
ttl,
17+
'DynamoDB'
18+
);
1519
}
1620

17-
function dynamoDBFeatureStoreInternal(tableName, options) {
21+
function dynamoDBFeatureStoreInternal(tableName, options, sdkLogger) {
1822
options = options || {};
19-
var logger = (options.logger ||
20-
new winston.Logger({
21-
level: 'info',
22-
transports: [
23-
new (winston.transports.Console)(),
24-
]
25-
})
26-
);
23+
var logger = options.logger || sdkLogger;
2724
var dynamoDBClient = options.dynamoDBClient || new AWS.DynamoDB.DocumentClient(options.clientOptions);
2825
var prefix = options.prefix || '';
2926

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ declare module 'launchdarkly-node-server-sdk-dynamodb' {
5656

5757
/**
5858
* A logger to be used for warnings and errors generated by the feature store. If not specified,
59-
* the default is an instance of winston.Logger.
59+
* it will use the SDK's logging configuration.
6060
*/
6161
logger?: LDLogger;
6262
}

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
"transformIgnorePatterns": []
3434
},
3535
"dependencies": {
36-
"node-cache": "4.2.0",
37-
"winston": "2.4.1"
36+
"node-cache": "4.2.0"
3837
},
3938
"peerDependencies": {
4039
"aws-sdk": "^2.349.0",

tests/dynamodb_feature_store-test.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ describe('DynamoDBFeatureStore', function() {
2525

2626
var table = 'test-store';
2727

28+
const sdkConfig = { logger: stubLogger() };
29+
2830
beforeAll(function(done) {
2931
dynamodb.describeTable({ TableName: table }, function(err) {
3032
if (!err) {
@@ -93,15 +95,15 @@ describe('DynamoDBFeatureStore', function() {
9395
}
9496

9597
function makeStore() {
96-
return new DynamoDBFeatureStore(table);
98+
return DynamoDBFeatureStore(table)(sdkConfig);
9799
}
98100

99101
function makeStoreWithoutCache() {
100-
return new DynamoDBFeatureStore(table, {cacheTTL: 0});
102+
return DynamoDBFeatureStore(table, {cacheTTL: 0})(sdkConfig);
101103
}
102104

103105
function makeStoreWithPrefix(prefix) {
104-
return new DynamoDBFeatureStore(table, {prefix: prefix, cacheTTL: 0});
106+
return DynamoDBFeatureStore(table, {prefix: prefix, cacheTTL: 0})(sdkConfig);
105107
}
106108

107109
function makeStoreWithDefaultPrefix() {
@@ -139,7 +141,7 @@ describe('DynamoDBFeatureStore', function() {
139141
beforeEach(() => {
140142
client = {};
141143
logger = stubLogger();
142-
store = new DynamoDBFeatureStore(table, { dynamoDBClient: client, logger: logger });
144+
store = DynamoDBFeatureStore(table, { dynamoDBClient: client })({ logger });
143145
});
144146

145147
it('error from query in init', done => {

0 commit comments

Comments
 (0)