Skip to content

Commit 27c0020

Browse files
fix: Improve logs
1 parent b640470 commit 27c0020

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

src/configuration/getConfigFromWizard.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,7 @@ export async function getConfigFromWizard({
296296

297297
if (save) {
298298
// save to file that looks like this:
299-
300-
Logger.log("Saving to config file");
299+
Logger.log(`Saving to config file ${configFileName}`);
301300

302301
const configContent = `
303302
import { type LldConfigTs } from "lambda-live-debugger";

src/lambdaConnection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async function onMessageFromLambda(message: IoTMessage) {
7575
} else {
7676
// first 50 characters of the response
7777
const requestPretty = message.data
78-
? JSON.stringify(message.data).substring(0, 50)
78+
? JSON.stringify(message.data).substring(0, 100)
7979
: "";
8080
Logger.log(
8181
`${message.data.functionId} request: ${requestPretty}${requestPretty.length < 50 ? "" : "..."}`
@@ -92,7 +92,7 @@ async function onMessageFromLambda(message: IoTMessage) {
9292
} else {
9393
// first 50 characters of the response
9494
const responsePretty = response
95-
? JSON.stringify(response).substring(0, 50)
95+
? JSON.stringify(response).substring(0, 100)
9696
: "";
9797
Logger.log(
9898
`${message.data.functionId} response: ${responsePretty}${responsePretty.length < 50 ? "" : "..."}`

src/nodeWorker.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,21 @@ async function runInWorker(input: {
4040
}
4141

4242
worker.on("message", (msg) => {
43-
Logger.log("Worker message", msg);
43+
Logger.verbose(
44+
`[Function ${input.fuctionRequest.functionId}] [Worker ${input.fuctionRequest.workerId}] Worker message`,
45+
JSON.stringify(msg)
46+
);
4447
if (msg?.errorType) {
4548
reject(msg);
4649
} else {
4750
resolve(msg);
4851
}
4952
});
5053
worker.on("error", (err) => {
51-
Logger.log("Worker error", err);
54+
Logger.error(
55+
`[Function ${input.fuctionRequest.functionId}] [Worker ${input.fuctionRequest.workerId}] Error`,
56+
err
57+
);
5258
reject(err);
5359
});
5460

src/vsCode.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ async function writeConfiguration(
142142
const modifiedJsonString = applyEdits(jsonString, edits);
143143

144144
// Write the modified JSON string back to the file
145+
Logger.verbose(`Adding to VsCode configuration file: ${filePath}`);
145146
await fs.writeFile(filePath, modifiedJsonString, "utf-8");
146147
} catch (err) {
147148
Logger.error(`Error writing the file: ${err}`);
@@ -187,19 +188,21 @@ async function getCurrentState(): Promise<
187188
});
188189

189190
if (!exists) {
191+
Logger.verbose(`${filePath} exists but configuration does not exist!`);
190192
return {
191193
state: "FILE_EXISTS_CONFIGURATION_DOES_NOT_EXIST",
192194
jsonString,
193195
configurationsLength: existingConfig.configurations?.length || 0,
194196
filePath,
195197
};
196198
} else {
197-
Logger.log("Configuration already exists!");
199+
Logger.verbose(`Configuration already exists in ${filePath}`);
198200
return {
199201
state: "FILE_EXISTS_CONFIGURATION_EXISTS",
200202
};
201203
}
202204
} else {
205+
Logger.verbose(`${filePath} does not exist!`);
203206
return {
204207
state: "FILE_DOES_NOT_EXIST",
205208
filePath,
@@ -236,6 +239,7 @@ async function addConfiguration(lldConfig: LldConfig) {
236239
// crete folder of filePath recursive if not exists
237240
await fs.mkdir(path.dirname(state.filePath), { recursive: true });
238241

242+
Logger.verbose(`Creating VsCode configuration file: ${state.filePath}`);
239243
await fs.writeFile(
240244
state.filePath,
241245
JSON.stringify(config, null, 2),

0 commit comments

Comments
 (0)