Skip to content

How to remove the filename+linenumber? #122

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

Closed
ariel-frischer opened this issue Oct 18, 2024 · 7 comments · Fixed by #121
Closed

How to remove the filename+linenumber? #122

ariel-frischer opened this issue Oct 18, 2024 · 7 comments · Fixed by #121

Comments

@ariel-frischer
Copy link

ariel-frischer commented Oct 18, 2024

Hey really want to just remove the filename:linenumber from my print statements but I'm not sure if there is an option for that?

I've tried messing with all of these options to no avail:

    opts = {
      -- remove the DEBUGPRINT tag
      print_tag = "",
      display_counter = false,
      display_snippet = false,
      filetypes = {
        python = {
          left = 'print(f"',
          left_var = 'print(f"',
          mid_var = '{',
          right_var = '}"',
          right = '")',
        },
      },
    },

I still get something like this:

    configuration = Configuration.from_runnable_config(config)
    print(f": tools.py:35: configuration={configuration}")

But I want this:

    print(f"configuration={configuration}")

How?

@andrewferrier
Copy link
Owner

There's currently no built in way to do this, but I can consider adding something. To help me understand the right way to do it: what's your motivation here? Why do you want to remove the filename/line number? Is this true for every debug line you want to implement? What about non-variable debug lines? Do you use those?

@ariel-frischer
Copy link
Author

ariel-frischer commented Oct 19, 2024

The logs just feel a bit cluttered, and when I'm making multiple edits the line numbers keep changing. I know the file most of the time. I mostly (like 95%) using this plugin with variable debug lines. I would assume if it is a non-variable debug line it would be more useful to keep the file:linenumber syntax.

@andrewferrier
Copy link
Owner

Hmm ok, fair, I can see that. Let me think about the right way to make that configurable, I'm definitely open to that.

@andrewferrier
Copy link
Owner

andrewferrier commented Oct 22, 2024

I think I'm going to implement this in two pieces:

  • Allow print_tag to be set to "", which will disable the additional : . If this is done, I want to issue some kind of warning when running DeleteDebugPrints or CommentDebugPrints, since there is no way for it to operate - resolved in 4e84b47.
  • Add an option called display_location, which defaults to true. If set to false it removes the filename and linenumber. If all display_* options are set to false, as well as print_tag, so that a plain debug line is about to emit effectively an empty output, display_location will effectively be forced to true for that line. This will not be true for 'variable' lines.

andrewferrier added a commit that referenced this issue Oct 22, 2024
Part of resolution for issue #122
@andrewferrier
Copy link
Owner

Hi - you should now find the option display_location added to the version on the main branch. If you set up debugprint with print_tag = "", display_location = false, display_counter = false, display_snippet = false, I think the variable debug print will now do what you were originally looking for!

Please let me know how this works for you and if you spot any issues.

@ariel-frischer
Copy link
Author

ariel-frischer commented Oct 24, 2024

Awesome its working well on my end! Thanks for implementing so quickly its a great plugin.

@andrewferrier
Copy link
Owner

Excellent, that's great, thanks for the quick feedback.

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 a pull request may close this issue.

2 participants