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

Debug output unusable when commands args contain large strings #521

Closed
iamjochem opened this issue Sep 14, 2017 · 2 comments
Closed

Debug output unusable when commands args contain large strings #521

iamjochem opened this issue Sep 14, 2017 · 2 comments

Comments

@iamjochem
Copy link
Contributor

hi there,

I love the fact that you use the debug module, it makes tracing what's going on in our own app as well as it's dependencies (in this case ioredis) a breeze.

I have stumbled upon a situation where I want to see the debug output from ioredis but due to the nature of what I happen to be storing the output is so large that it's making the console output unusable (actually my terminal regularly locks up in this particular situation).

What am I doing?

I'm storing "large" strings (JSON data) for caching purposes.

What am I seeing?

I'm see debug output along the lines of:

ioredis:redis write command[0] -> set("cache_data_1234",{"here_be":"lots of JSON",
.... hunderds/thousands of lines of output in my console ....
}) +337ms

What would I like to see?

Something along the lines of:

ioredis:redis write command[0] -> set("cache_data_1234",<large_arg_redacted>) +337ms

Discuss?

Would you be willing to accept a PR that manipulates the command.args that are included in the debug output so that "large" strings are redacted?

If yes, what do you feel regarding:

  1. what the redaction string should be? (in my example I used <large_arg_redacted>)
  2. what should be the length threshold for string threshold?
  3. should the threshold be configurable?
  4. should there be somekind of config option and/or ENV var that can be used to turn off the redaction completely?

thanks for taking the time to read, look forward to your reply!

@luin
Copy link
Collaborator

luin commented Sep 17, 2017

PR is welcome! To your questions:

what the redaction string should be? (in my example I used <large_arg_redacted>)

I'd recommend printing the heading several chars of the large argument to provide more details for developers to debug. For example: foobarfoobarfoobar<...8292 more chars>. (I'm not a native speaker so I'm open to any suggestions.

what should be the length threshold for string threshold?

50~200 should be enough as for me.

should the threshold be configurable?

I don't think an option is needed for that.

should there be somekind of config option and/or ENV var that can be used to turn off the redaction completely?

The same answer as above. Let's make it default.

@iamjochem
Copy link
Contributor Author

hi @luin,

as promised here is a PR: #523

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