Skip to content

Commit

Permalink
Merge pull request #36 from teamplanes/next
Browse files Browse the repository at this point in the history
fix: logs should include cdk path not function name
  • Loading branch information
kirkness authored Nov 16, 2021
2 parents 771fc1b + c08ee58 commit f2638a3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit
yarn commitlint --edit
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"bin": {
"cdkw": "lib/cli.js"
},
"version": "0.0.24",
"version": "0.0.25-next.3",
"scripts": {
"type-check": "tsc -p tsconfig.json --noEmit",
"build": "tsup src/index.ts src/cli.ts src/index.ts src/websocketHandlers/index.ts src/lambda-extension/cdk-watch-lambda-wrapper/index.ts --no-splitting -d lib --clean --dts=src/index.ts",
Expand Down
21 changes: 11 additions & 10 deletions src/lib/tailLogsForLambdas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ const tailLogsForLambdas = async (
: Object.keys(realTimeEndpointsForLambdas).filter(
(key) => !realTimeEndpointsForLambdas[key],
)
)
.map((key) => {
const found = lambdaFunctions.find((func) => func.lambdaCdkPath === key);
if (!found) throw new Error('Lambda key not found'); // should never happen.
return found;
})
.map(({functionName}) => functionName);
).map((key) => {
const found = lambdaFunctions.find((func) => func.lambdaCdkPath === key);
if (!found) throw new Error('Lambda key not found'); // should never happen.
return found;
});

// Keyed by the endpoint, values are arrays of lambda details
const realTimeLogsFunctionMap = forceCloudwatch
Expand All @@ -44,9 +42,12 @@ const tailLogsForLambdas = async (
};
}, {} as Record<string, LambdaDetail[]>);

cloudwatchFunctions.forEach((name) => {
const logger = createCLILoggerForLambda(name, lambdaFunctions.length > 1);
tailCloudWatchLogsForLambda(name)
cloudwatchFunctions.forEach((lambda) => {
const logger = createCLILoggerForLambda(
lambda.lambdaCdkPath,
lambdaFunctions.length > 1,
);
tailCloudWatchLogsForLambda(lambda.functionName)
.on('log', (log) => logger.log(log.toString()))
.on('error', (log) => logger.error(log));
});
Expand Down

0 comments on commit f2638a3

Please sign in to comment.