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

Refactor all logging to go through a logger object #10249

Merged
merged 3 commits into from
Oct 30, 2024
Merged

Conversation

riknoll
Copy link
Member

@riknoll riknoll commented Oct 29, 2024

This PR is part one of my effort to add a backdoor for getting console logs from the ingame experience in minecraft.

i guess this is technically a breaking change, because pxt.log used to be a function that could be overwritten, but AFAIK we never actually did that so i think we should be good.

@riknoll riknoll requested a review from a team October 29, 2024 23:28
@abchatra
Copy link
Collaborator

This was quick and awesome.

@srietkerk
Copy link
Contributor

srietkerk commented Oct 29, 2024

i guess this is technically a breaking change, because pxt.log used to be a function that could be overwritten, but AFAIK we never actually did that so i think we should be good.

I don't understand why this is a breaking change. The new logger stuff that you made is completely separate from pxt.log, right? And since it's only in pxtsim and will only be used in Minecraft shouldn't the other, generic pxt.log be unaffected?

@@ -0,0 +1,67 @@
namespace pxt {
Copy link
Contributor

Choose a reason for hiding this comment

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

I take it there's no nice, shared location both pxtsim and pxtlib can consume this from as a single file?

Copy link
Member Author

Choose a reason for hiding this comment

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

nope...

}
// console.log(`${mkIndent(depth)}REFS: ${referenced}`)
// pxt.log(`${mkIndent(depth)}REFS: ${referenced}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not get rid of these commented out logs? Will we ever reenable them? Or are they just used in dev scenarios and we want to leave them here for quick access?

Copy link
Member Author

Choose a reason for hiding this comment

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

i dunno! i didn't add them, so i'm not touching them :)

Copy link
Contributor

@thsparks thsparks left a comment

Choose a reason for hiding this comment

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

Nice!

@@ -200,7 +200,7 @@ export class Editor extends srceditor.Editor {
}
if (this.isVisible) {
if (this.isCsvView && !this.receivedCsv) {
// have not received a csv yet but in csv view; swap back to console.
// have not received a csv yet but in csv view; swap back to pxt.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not 100% sure what this comment is referring to, but my guess is it should still be "console" here?

@riknoll
Copy link
Member Author

riknoll commented Oct 30, 2024

@srietkerk this redefines pxt.log

it was previously a variable that pointed to a function, so you could overwrite it. with this change, it's now just a function. you can still overwrite with monkey patching but TS will complain

@riknoll riknoll merged commit 995ee2c into master Oct 30, 2024
6 checks passed
@riknoll riknoll deleted the dev/riknoll/logger branch October 30, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants