Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: logging #360

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/sdk/src/getEventMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export async function getEventMessages<T extends SchemaType>(
entity_models: entityModels,
clause,
dont_include_hashed_keys: false,
order_by: [],
};

try {
Expand Down
7 changes: 2 additions & 5 deletions packages/state/src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,8 @@ describe("convertValues", () => {
ids: ["invalid_bigint"],
};
expect(convertValues(schema, values)).toEqual(expected);

// TODO: fix console mocking
// expect(consoleSpy).toHaveBeenCalled();
// expect(consoleSpy).toHaveBeenCalledWith(
// "Failed to convert invalid_bigint to BigInt. Using string value instead."
// expect(console.warn).toHaveBeenCalledWith(
// "Failed to convert invalid_bigint to BigInt. Using string value instead."
// );
});

Expand Down
9 changes: 5 additions & 4 deletions packages/state/src/recs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export const getEntities = async <S extends Schema>(
dont_include_hashed_keys: false,
});

console.log("entities", entities);
if (logging) console.log("entities", entities);

if (logging) console.log(`Fetched ${entities} entities`);

Expand Down Expand Up @@ -442,9 +442,10 @@ export const setEntities = async <S extends Schema>(
);
}
} else {
console.warn(
`Component ${componentName} not found in provided components.`
);
if (logging)
console.warn(
`Component ${componentName} not found in provided components.`
);
Comment on lines +445 to +448
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Reconsider gating critical warning messages

While the change aligns with reducing logging, missing components might indicate a critical issue that developers should always be aware of. Consider keeping this warning unconditional or using a different logging level (error) that's always enabled.

Consider reverting this change or using error logging:

-                if (logging)
-                    console.warn(
-                        `Component ${componentName} not found in provided components.`
-                    );
+                console.error(
+                    `Component ${componentName} not found in provided components.`
+                );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (logging)
console.warn(
`Component ${componentName} not found in provided components.`
);
console.error(
`Component ${componentName} not found in provided components.`
);

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion worlds/dojo-starter
Loading