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

--liveserver-verbose and --liveserver-debug command-line arguments #1024

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mpasternak
Copy link

Basing on my usage and on StackOverflow questions, the world needs --liveserver-verbose command line argument, which this branch implements.

Default live server is quiet. Django guys made it quiet. And, well, for some, maybe this is good. Because theory says that you're supposed to have a lot of unit tests and when you start integration testing all your code should be A1-OKAY and 100% tested... in an ideal world.

... but in this world, I tend to stumble on "500 ERROR" spewed by LiveServer at my code. Unable to debug, unable to print stuff to the console. Helpless, really. Especially helpless, when I know that everything in the code is okay and the error is because of environment problems. But still, unable to debug it, I feel helpless.

And I don't like the feeling of being helpless.

So I present to you the --liveserver-verbose argument.

It prints stuff on the stdout!

It can even print out a backtrace.

Is it ugly? Yes.

Can it be improved? Yes! Just like pytest-durations, it would be lovely to have some frames and a nicely formatted output.

But... I almost pressed "CREATE PULL REQUEST" here... I can improve it already.

Another option I present to you is liveserver-debug. This option drops to debugger in the console when a traceback occurs.

Am I cool now? Am I the good guy? Can I take constructive criticism? Was I able to do all of that without switches on the command line? LET'S SEE!

What I would really like to see with this branch is how to collect those stdout texts nicely. If I don't use -s switch it prints out stderr on failing tests nicely. Perhaps you can help me improve this. Thanks!

How to see output from LiveServer when it fails? It was a difficult task, as official Django tests make it quiet... until now.
@mpasternak
Copy link
Author

Looks like I can't request review. @bluetech @hramezani I saw you helped with a few recent merges, would you like to check it out?

@mpasternak mpasternak changed the title Feature/verbose liveserver --liveserver-verbose and --liveserver-debug command-line argument s Sep 6, 2022
@mpasternak mpasternak changed the title --liveserver-verbose and --liveserver-debug command-line argument s --liveserver-verbose and --liveserver-debug command-line arguments Sep 6, 2022
@mpasternak
Copy link
Author

Review required!

@AngelOnFira
Copy link

Thanks for doing this @mpasternak, I hope it gets merged because it does just work :)

I did just try using this locally, and I ran into a problem with the following code:

class VerboseLiveServerThread(LiveServerThread):
    request_handler_class = VerboseWSGIRequestHandler

    def _create_server(self):
        return ThreadedWSGIServer(
            (self.host, self.port),
            self.request_handler_class,
            allow_reuse_address=False
        )

due to this commit to Django: django/django@855f5a3 making a change to how _create_server is called:

self.httpd = self._create_server(
    connections_override=self.connections_override,
)

I fixed it by just adding an optional argument:

def _create_server(self, connections_override={}):

I don't know if this is the cleanest fix, but it works for me right now :)

@mpasternak
Copy link
Author

Thanks for some kind words. It’s been almost a year since I posted this. Obviously nobody runs into problems with live server except me. And maybe some people on StackOverflow 🤣

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.

None yet

2 participants