Skip to content

Commit 4e01269

Browse files
authored
Merge pull request #57 from ashiina/develop
release 1.3.0
2 parents b64ab82 + 917a7cd commit 4e01269

File tree

6 files changed

+52
-18
lines changed

6 files changed

+52
-18
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# ChangeLog
22

3+
## 1.3.0 (2016/11/26)
4+
* Fixed critical bug (logger)
5+
36
## 1.2.0 (2016/11/23)
47
* Added mock functionality
58
* Dropped Node.js v0.1, v0.12 suport

REQUIRE_SAMPLES.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ Then you will be able to use in your test.js mocha file, something like:
7272
cb();
7373
}
7474
});
75-
describe("Your first test", function () {
76-
it("should return mocked value", function () {
77-
assert.equal(done, "MockedData");
78-
});
75+
});
76+
describe("Your first test", function () {
77+
it("should return mocked value", function () {
78+
assert.equal(done, "MockedData");
7979
});
80-
... Other tests
8180
});
81+
... Other tests
8282
```
8383

8484
[1]: https://mochajs.org/

bin/lambda-local

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
*/
88
(function() {
99

10-
var winston = require('winston');
11-
var logger = new winston.Logger({
12-
level: 'info',
13-
transports: [
14-
new (winston.transports.Console)({handleExceptions: true, json: false, colorize: true})
15-
]
16-
});
10+
var logger = require('winston');
11+
logger.level = 'info';
12+
logger.configure({
13+
transports: [
14+
new (logger.transports.Console)({handleExceptions: true, json: false, colorize: true})
15+
]
16+
});
1717

1818
var lambdaLocal = require('../lib/lambdalocal.js'),
1919
utils = require('../lib/utils.js');
20-
lambdaLocal.setLogger(logger);
20+
lambdaLocal.setLogger(logger);
2121

2222
// process opts
2323
var program = require('commander');

lib/lambdalocal.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ var _setLogger = function(_logger){
1616
if(_logger != null && typeof _logger.loggers != 'undefined'){
1717
logger = _logger;
1818
} else {
19-
throw new TypeError("The object must be a winston logger !");
19+
console.warn("Invalid logger object ! Using default logger");
2020
}
2121
}
22-
22+
23+
var _getLogger = function() {
24+
return logger;
25+
}
26+
2327
var _execute = function(opts) {
2428
var event = opts.event,
2529
lambdaFunc = opts.lambdaFunc,
@@ -88,5 +92,6 @@ var _execute = function(opts) {
8892
module.exports = {
8993
context: _context,
9094
execute: _execute,
91-
setLogger: _setLogger
95+
setLogger: _setLogger,
96+
getLogger: _getLogger
9297
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lambda-local",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "Commandline tool to run Lambda functions on your local machine.",
55
"keywords": [
66
"lambda",

test/test.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,32 @@ describe("- Testing utils.js", function () {
2828
});
2929
});
3030
});
31+
describe("- Testing lambdalocal.js Logger", function () {
32+
var lambdalocal = require("../lib/lambdalocal.js");
33+
var defaultLogger = lambdalocal.getLogger();
34+
describe("* Use winston logger", function () {
35+
it("should correctly load Logger", function () {
36+
lambdalocal.setLogger(winston);
37+
var logger = lambdalocal.getLogger();
38+
assert.equal(winston, logger);
39+
});
40+
});
41+
describe("* Use invalid logger (object)", function () {
42+
it("should load default Logger", function () {
43+
lambdalocal.setLogger(Object);
44+
var logger = lambdalocal.getLogger();
45+
assert.equal(logger, defaultLogger);
46+
});
47+
});
48+
describe("* Use null logger", function () {
49+
it("should load default Logger", function () {
50+
lambdalocal.setLogger(null);
51+
var logger = lambdalocal.getLogger();
52+
assert.equal(logger, defaultLogger);
53+
});
54+
});
55+
});
56+
3157
describe("- Testing lambdalocal.js", function () {
3258
describe("* Basic Run", function () {
3359
var done, err;
@@ -127,4 +153,4 @@ describe("- Testing lambdalocal.js", function () {
127153
});
128154
});
129155
});
130-
});
156+
});

0 commit comments

Comments
 (0)