diff --git a/README.md b/README.md index b6a1527..80f7723 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/src/cli.ts b/src/cli.ts index e3c6b87..68f80bc 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -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 ', '(optional) Load additional environment variables from a file') .option('--inspect [[host:]port]', @@ -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) { @@ -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(); } diff --git a/src/lib/context.ts b/src/lib/context.ts index fa684ee..a20c3fb 100644 --- a/src/lib/context.ts +++ b/src/lib/context.ts @@ -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; diff --git a/test/test.js b/test/test.js index 9206766..4501639 100644 --- a/test/test.js +++ b/test/test.js @@ -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 () {