liveperson-functions-cli
Version:
LivePerson Functions CLI
67 lines • 2.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const logs_controller_1 = require("../controller/logs.controller");
const utils_1 = require("../shared/utils");
const printer_1 = require("../view/printer");
class Logs extends core_1.Command {
constructor() {
super(...arguments);
this.errorMessage = new printer_1.ErrorMessage();
}
/**
* Runs the invoke command and parses the passed function and flag
* @returns {Promise<void>} - invoke command
* @memberof Invoke
*/
async run() {
try {
const { flags: inputFlags } = await this.parse(Logs);
const [lambdaFunction] = (0, utils_1.parseInput)(Logs.flags, this.argv);
await logs_controller_1.LogsController.getLogs({ lambdaFunction, inputFlags });
}
catch (error) {
this.errorMessage.print(error.message || error.errorMsg);
this.exit(1);
}
}
}
exports.default = Logs;
Logs.description = 'Download function logs as CSV (limited to the first 500 logs of the provided timespan)';
Logs.flags = {
help: core_1.Flags.help({ char: 'h' }),
start: core_1.Flags.string({
char: 's',
description: 'start timestamp',
required: true,
}),
removeHeader: core_1.Flags.boolean({
char: 'r',
description: 'Removes the header of the logs',
default: false,
}),
end: core_1.Flags.string({
char: 'e',
description: 'end timestamp (default current timestamp)',
}),
levels: core_1.Flags.string({
char: 'l',
description: 'log-levels - for multiple levels just use levels with space separated (e.g. -l Info Warn)',
options: ['Info', 'Warn', 'Error'],
multiple: true,
}),
};
Logs.args = [{ name: 'function-name' }];
Logs.examples = [
'> <%= config.bin %> logs exampleFunction --start=1626156400000',
'> <%= config.bin %> logs exampleFunction --start=1626156400000 --end=1626157400000',
'> <%= config.bin %> logs exampleFunction --start=1626156400000 --levels=Info Warn',
'',
'For redirecting logs to a file:',
'logs exampleFunction --start=1626156400000 > exampleFunction.log',
'',
'Fetching logs via cronjob every 10 minutes (delayed by 1 minute to be sure no logs are missed) and write it to a file:',
'MacOS:',
'1/10 * * * * <%= config.bin %> logs exampleFunction --start=$(date -v0S -v-11M +%s000) --end=$(date -v0S -v-1M +%s000) >> exampleFunction.log',
];
//# sourceMappingURL=logs.js.map