Skip to content

Commit

Permalink
Add verboseLevel -1
Browse files Browse the repository at this point in the history
closes #242
  • Loading branch information
gpotter2 committed Apr 13, 2024
1 parent 53814cb commit b7a2ed0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -68,7 +68,7 @@ Executes a lambda given the `options` object, which is a dictionary where the ke
| `environment`|optional, extra environment variables for the lambda|
| `envfile`|optional, load an environment file before booting|
| `envdestroy`|optional, destroy added environment on closing, default to false|
| `verboseLevel`|optional, default 3. Level 2 dismiss handler() text, level 1 dismiss lambda-local text and level 0 dismiss also the result.|
| `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.|
| `callback`|optional, lambda third parameter [callback][1]. When left out a Promise is returned|
| `onInvocationEnd`|optional. called once the invocation ended. useful when awslambda.streamifyResponse is used to distinguish between end of response stream and end of invocation. |
| `clientContext`|optional, used to populated clientContext property of lambda second parameter (context)
Expand Down
11 changes: 8 additions & 3 deletions src/cli.ts
Expand Up @@ -38,9 +38,9 @@ import utils = require('./lib/utils');
'returning. This is false by default because our implementation isn\'t perfect and only "emulates" it.')
.option('--envdestroy',
'(optional) Destroy added environment on closing. Defaults to false')
.option('-v, --verboselevel <3/2/1/0>',
.option('-v, --verboselevel <3/2/1/0/-1>',
'(optional) Default 3. Level 2 dismiss handler() text, level 1 dismiss lambda-local text ' +
'and level 0 dismiss also the result.', 3)
'and level 0 dismiss also the result. Level -1 only displays handler() text.', 3)
.option('--envfile <path/to/env/file>',
'(optional) Load additional environment variables from a file')
.option('--inspect [[host:]port]',
Expand All @@ -60,7 +60,7 @@ import utils = require('./lib/utils');
envdestroy = program.envdestroy,
envfile = program.envfile,
callbackWaitsForEmptyEventLoop = program.waitEmptyEventLoop,
verboseLevel = program.verboselevel;
verboseLevel = parseInt(program.verboselevel);

var port;
if (program.watch) {
Expand All @@ -73,6 +73,11 @@ import utils = require('./lib/utils');
eventPath = true;
}

if (isNaN(verboseLevel)) {
console.log("Invalid verboseLevel. Must be number.");
process.exit(1);
}

if (!lambdaPath || !eventPath) {
program.help();
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/context.ts
Expand Up @@ -110,7 +110,7 @@ Context.prototype._initialize = function(options) {
if (this.verboseLevel > 1){
this.logger.log('info', 'START RequestId: ' + this.awsRequestId);
}
if (this.verboseLevel < 3){
if (this.verboseLevel < 3 && this.verboseLevel >= 0){
this.unmute = mute();
}
this.clientContext = options.clientContext;
Expand Down
7 changes: 7 additions & 0 deletions test/test.js
Expand Up @@ -749,6 +749,13 @@ describe("- Testing cli.js", function () {
assert.equal(r.status, 0);
assert.equal(r.output, "");
});
it("should have only console output", function () {
var command = get_shell("node ../build/cli.js -l ./functs/test-func-print.js -e ./events/test-event.js -v -1");
var r = spawnSync(command[0], command[1]);
process_outputs(r);
assert.equal(r.status, 0);
assert.equal(r.output, "Function running :)\n");
});
});
if (get_node_major_version() >= 16) {
describe("* Test --wait-empty-event-loop", function () {
Expand Down

0 comments on commit b7a2ed0

Please sign in to comment.