mar10 / wsgidav

A generic and extendable WebDAV server based on WSGI

Home Page:https://wsgidav.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to print error message with trace back

HengyueLi opened this issue · comments

commented

I am building my own Provider. When code running error, in the browser I can see

500 Internal Server Error
500 Internal Server Error: An internal server error occurred Source exception: ''

(No details of what is wrong)
As code in Provider increases, it becomes more and more difficult to debug.
Is it possible to print all messages with traces back anywhere? Setting "verbose": 5 seems not work.

my running code is:

...
server_args = {
    "bind_addr": (config["host"], config["port"]),
    "wsgi_app": app,
}
server = wsgi.Server(**server_args)
server.start()
commented

To simplify the problem, I write a bug as follows:
For the definition of provider, I defined

    def get_display_name(self) -> str:
        assert 1==2

This will cause the problem. And I cannot find a place to indicate to me that the problem is here.

This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

Did you find a workaround? I'm also trying to get helpful error messages while developing a custom provider, but they just won't show up.

commented

I did not find any good workaround. Just increasing many print in the code with bisection debugging.

Did you find a workaround? I'm also trying to get helpful error messages while developing a custom provider, but they just won't show up.

See #285 for a suggestion

Thanks, the

from wsgidav.util import init_logging
init_logging(config)

did the trick.

I was following this example from the documentation, so maybe it would be useful for others to add these lines to the example.

The logging section on the same page is also a bit tricky, I already tried to configure it using the following lines:

logger = logging.getLogger("wsgidav")
logger.propagate = True
logger.setLevel(logging.DEBUG)

which won't show the error messages. The error messages only show up when the commented-out line logging.basicConfig(level=logging.DEBUG) is added.

In hindsight it all looks pretty simple to get right, but I couldn't figure it out by myself in half an hour. Maybe the example should be updated to log error messages by default so less people get stuck.

Thanks for the awesome project and the fast help!

v4.3.0 will have an easier way to configure this, I will update the docs accordingly.
Thanks for the feedback.