Skip to content

Commit

Permalink
Update logDebug to take an optional data parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
thsparks committed Apr 11, 2024
1 parent f9e3edc commit 446b0f2
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
5 changes: 3 additions & 2 deletions teachertool/src/services/loggingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ export const logInfo = (message: any) => {
console.log(timestamp(), message);
};

export const logDebug = (message: any) => {
export const logDebug = (message: any, data?: any) => {
if (pxt.BrowserUtils.isLocalHost() || pxt.options.debug) {
console.log(timestamp(), message);
console.log(timestamp(), message, data);
}
};

4 changes: 2 additions & 2 deletions teachertool/src/services/makecodeEditorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export function setEditorRef(ref: HTMLIFrameElement | undefined) {
driver = new EditorDriver(ref);

driver.addEventListener("message", ev => {
logDebug(`Message received from iframe: ${JSON.stringify(ev)}`);
logDebug(`Message received from iframe. ID: ${ev?.id}`, ev);
});
driver.addEventListener("sent", ev => {
logDebug(`Sent message to iframe: ${JSON.stringify(ev)}`);
logDebug(`Sent message to iframe. ID: ${ev?.id}`, ev);
});
driver.addEventListener("editorcontentloaded", ev => {
AutorunService.poke();
Expand Down
2 changes: 1 addition & 1 deletion teachertool/src/transforms/getRubricFromFileAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function getRubricFromFileAsync(file: File, allowPartial: boolean):
let rubric = await loadRubricFromFileAsync(file);

if (rubric) {
logDebug(`Loading rubric '${rubric.name}' from file...`);
logDebug("Loading rubric from file...", {file, rubric});

const rubricVerificationResult = verifyRubricIntegrity(rubric);

Expand Down
2 changes: 1 addition & 1 deletion teachertool/src/transforms/loadProjectMetadataAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ export async function loadProjectMetadataAsync(inputText: string, shareLink: str
};
dispatch(Actions.setProjectMetadata(projectData));
initNewProjectResults();
logDebug(`Loaded project metadata: ${JSON.stringify(projMeta)}`);
logDebug("Loaded project metadata", projMeta);
}
1 change: 0 additions & 1 deletion teachertool/src/transforms/setActiveTab.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { logDebug } from "../services/loggingService";
import { stateAndDispatch } from "../state";
import * as Actions from "../state/actions";
import { TabName } from "../types";
Expand Down
2 changes: 1 addition & 1 deletion teachertool/src/transforms/tryLoadLastActiveRubricAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function tryLoadLastActiveRubricAsync() {
const lastActiveRubric = await getLastActiveRubricAsync();

if (lastActiveRubric) {
logDebug(`Loading last active rubric '${lastActiveRubric.name}'...`);
logDebug("Loading last active rubric...", lastActiveRubric);

const rubricVerificationResult = verifyRubricIntegrity(lastActiveRubric);

Expand Down

0 comments on commit 446b0f2

Please sign in to comment.