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

How to use log module? #28

Open
lgtinsea opened this issue May 19, 2023 · 3 comments
Open

How to use log module? #28

lgtinsea opened this issue May 19, 2023 · 3 comments

Comments

@lgtinsea
Copy link

I see log module in tree-sitter. Someone introduce the usage in tree-sitter/tree-sitter#1129.
Can anyone tell me how to use log module in java-tree-sitter to get the log of c/cpp code?

@sogaiu
Copy link

sogaiu commented May 19, 2023

A cursory glance at this suggests there may not be any code that exposes the functionality to Java.

If there were, I think one would find traces of TSLogger (I didn't find any among .java or .cc files via grep). For comparison, for the Rust bindings, there is evidence here and for the web-tree-sitter / wasm code there is this.

@lgtinsea
Copy link
Author

Thank you very much for your help. I couldn't find the relevant code either, so I'm here to see if there's a miracle.

By the way, debugging when java calls c/cpp code is is a little difficult.

@sogaiu
Copy link

sogaiu commented May 22, 2023

IIUC, by default, the TSLogger functionality is specifically tied to calls made from the parser (implemented in C - parser.c).

If it is working I think you end up seeing the results of calls to LOG and LOG_LOOKAHEAD, e.g. like this because they both call ts_parser__log.

The tree-sitter command line program uses TSLogger via its parse subcommand with --debug / -D. There is a discussion and an issue at the tree-sitter repository that touches on some of the related details. Some people (e.g. tree-sitter grammar developers) use this functionality when investigating issues with the grammars they are working on.

For java-tree-sitter, it looks like the current maintainer has been busy / unavailable for some time, so it's unclear if / when logging functionality of the sort described above would be added.

dabico added a commit to seart-group/java-tree-sitter that referenced this issue Feb 15, 2024
This is one of the features missing from the original library.
Seems to be a feature desired by the community according to:
serenadeai/java-tree-sitter#28.
Therefore, it makes sense to advertise this in the README.
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

No branches or pull requests

2 participants