Skip to content

Commit b7a2ed0

Browse files
committed
Add verboseLevel -1
closes #242
1 parent 53814cb commit b7a2ed0

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Executes a lambda given the `options` object, which is a dictionary where the ke
6868
| `environment`|optional, extra environment variables for the lambda|
6969
| `envfile`|optional, load an environment file before booting|
7070
| `envdestroy`|optional, destroy added environment on closing, default to false|
71-
| `verboseLevel`|optional, default 3. Level 2 dismiss handler() text, level 1 dismiss lambda-local text and level 0 dismiss also the result.|
71+
| `verboseLevel`|optional, default 3. Level 2 dismiss handler() text, level 1 dismiss lambda-local text and level 0 dismiss also the result. Level -1 only displays handler() text.|
7272
| `callback`|optional, lambda third parameter [callback][1]. When left out a Promise is returned|
7373
| `onInvocationEnd`|optional. called once the invocation ended. useful when awslambda.streamifyResponse is used to distinguish between end of response stream and end of invocation. |
7474
| `clientContext`|optional, used to populated clientContext property of lambda second parameter (context)

src/cli.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ import utils = require('./lib/utils');
3838
'returning. This is false by default because our implementation isn\'t perfect and only "emulates" it.')
3939
.option('--envdestroy',
4040
'(optional) Destroy added environment on closing. Defaults to false')
41-
.option('-v, --verboselevel <3/2/1/0>',
41+
.option('-v, --verboselevel <3/2/1/0/-1>',
4242
'(optional) Default 3. Level 2 dismiss handler() text, level 1 dismiss lambda-local text ' +
43-
'and level 0 dismiss also the result.', 3)
43+
'and level 0 dismiss also the result. Level -1 only displays handler() text.', 3)
4444
.option('--envfile <path/to/env/file>',
4545
'(optional) Load additional environment variables from a file')
4646
.option('--inspect [[host:]port]',
@@ -60,7 +60,7 @@ import utils = require('./lib/utils');
6060
envdestroy = program.envdestroy,
6161
envfile = program.envfile,
6262
callbackWaitsForEmptyEventLoop = program.waitEmptyEventLoop,
63-
verboseLevel = program.verboselevel;
63+
verboseLevel = parseInt(program.verboselevel);
6464

6565
var port;
6666
if (program.watch) {
@@ -73,6 +73,11 @@ import utils = require('./lib/utils');
7373
eventPath = true;
7474
}
7575

76+
if (isNaN(verboseLevel)) {
77+
console.log("Invalid verboseLevel. Must be number.");
78+
process.exit(1);
79+
}
80+
7681
if (!lambdaPath || !eventPath) {
7782
program.help();
7883
}

src/lib/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Context.prototype._initialize = function(options) {
110110
if (this.verboseLevel > 1){
111111
this.logger.log('info', 'START RequestId: ' + this.awsRequestId);
112112
}
113-
if (this.verboseLevel < 3){
113+
if (this.verboseLevel < 3 && this.verboseLevel >= 0){
114114
this.unmute = mute();
115115
}
116116
this.clientContext = options.clientContext;

test/test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,13 @@ describe("- Testing cli.js", function () {
749749
assert.equal(r.status, 0);
750750
assert.equal(r.output, "");
751751
});
752+
it("should have only console output", function () {
753+
var command = get_shell("node ../build/cli.js -l ./functs/test-func-print.js -e ./events/test-event.js -v -1");
754+
var r = spawnSync(command[0], command[1]);
755+
process_outputs(r);
756+
assert.equal(r.status, 0);
757+
assert.equal(r.output, "Function running :)\n");
758+
});
752759
});
753760
if (get_node_major_version() >= 16) {
754761
describe("* Test --wait-empty-event-loop", function () {

0 commit comments

Comments
 (0)