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

request/question: How to access debug log stream #716

Closed
BusaniNdlovu opened this issue Jul 10, 2019 · 6 comments
Closed

request/question: How to access debug log stream #716

BusaniNdlovu opened this issue Jul 10, 2019 · 6 comments
Labels
awaiting-response This issue or pull request is awaiting a user's response question This issue asks a question or requests usage support

Comments

@BusaniNdlovu
Copy link

Greetings. Thank you for the amazing library. I'm curious as to how to access this libraries standard output and error stream. Is it printed and ephemeral or is it written to a file. My intention is to assert in my tests whether something was logged. Any insight would be much appreciated.

@Qix-
Copy link
Member

Qix- commented Jul 10, 2019

Definitely ephemeral, but you can override the .log property in order to process debug messages. However, it's not the most elegant API admittedly.

Check out #556 which would solve a lot of the testing needs, too. Not sure when it will be implemented.

Does that help?

@Qix- Qix- added awaiting-response This issue or pull request is awaiting a user's response question This issue asks a question or requests usage support labels Jul 10, 2019
@BusaniNdlovu
Copy link
Author

Thank you for the quick response. Yes, your insight is extremely helpful. I'll explore further. Else I'll implement some version of #192 .

@Qix-
Copy link
Member

Qix- commented Jul 10, 2019

Right now the ugly hack for Node would be to pass all of those strings to strip-ansi and then pass them to a file.

@BusaniNdlovu
Copy link
Author

Sounds fun. I'll get my hands dirty. Also, it just occured to me that it may prove effective to wrap a sinon spy around the debug function, then do a getCalls().args on it. I'll let you know how that pans out for the benefit of others. But otherwise you may close the issue.

@Qix-
Copy link
Member

Qix- commented Jul 10, 2019

You can definitely do that.

Keep in mind, however, that depending on how you're using debug, it might be an anti-pattern to test against what's passed to debug.

@BusaniNdlovu
Copy link
Author

Thank you. I willl :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-response This issue or pull request is awaiting a user's response question This issue asks a question or requests usage support
Development

No branches or pull requests

2 participants