Move debugger details into a new section, #343.
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Ron DuPlain · committed by Ron DuPlain · parent dfd3ef6 · Browse files · 2 files·+70 added−38 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+70 added−38 removed
- other:+70 added−38 removed
Provenance
- Commit
69e7a0a- Tree
f17252e- Author
Ron DuPlain <ron.duplain@gmail.com>- Committer
Ron DuPlain <ron.duplain@gmail.com>- Parent
dfd3ef6
2 files changed+70 added−38 removed
modified:docs/errorhandling.rst+67 added-2 removed
1 .. _application-errors:2 3-Handling Application Errors4-===========================3+Logging Application Errors4+==========================5 6 .. versionadded:: 0.37 8 Applications fail, servers fail. Sooner or later you will see an exception225 unmodified lines234 getLogger('otherlibrary')]235 for logger in loggers:236 logger.addHandler(mail_handler)237 logger.addHandler(file_handler)238+239+240+Debugging Application Errors241+============================242+243+For production applications, configure your application with logging and244+notifications as described in :ref:`application-errors`. This section provides245+pointers when debugging deployment configuration and digging deeper with a246+full-featured Python debugger.247+248+249+When in Doubt, Run Manually250+---------------------------251+252+Having problems getting your application configured for production? If you253+have shell access to your host, verify that you can run your application254+manually from the shell in the deployment environment. Be sure to run under255+the same user account as the configured deployment to troubleshoot permission256+issues. You can use Flask's builtin development server with `debug=True` on257+your production host, which is helpful in catching configuration issues, but258+**be sure to do this temporarily in a controlled environment.** Do not run in259+production with `debug=True`.260+261+262+.. _working-with-debuggers:263+264+Working with Debuggers265+----------------------266+267+To dig deeper, possibly to trace code execution, Flask provides a debugger out268+of the box (see :ref:`debug-mode`). If you would like to use another Python269+debugger, note that debuggers interfere with each other. You have to set some270+options in order to use your favorite debugger:271+272+* ``debug`` - whether to enable debug mode and catch exceptinos273+* ``use_debugger`` - whether to use the internal Flask debugger274+* ``use_reloader`` - whether to reload and fork the process on exception275+276+``debug`` must be True (i.e., exceptions must be caught) in order for the other277+two options to have any value.278+279+If you're using Aptana/Eclipse for debugging you'll need to set both280+``use_debugger`` and ``use_reloader`` to False.281+282+A possible useful pattern for configuration is to set the following in your283+config.yaml (change the block as approriate for your application, of course)::284+285+ FLASK:286+ DEBUG: True287+ DEBUG_WITH_APTANA: True288+289+Then in your application's entry-point (main.py), you could have something like::290+291+ if __name__ == "__main__":292+ # To allow aptana to receive errors, set use_debugger=False293+ app = create_app(config="config.yaml")294+295+ if app.debug: use_debugger = True296+ try:297+ # Disable Flask's debugger if external debugger is requested298+ use_debugger = not(app.config.get('DEBUG_WITH_APTANA'))299+ except:300+ pass301+ app.run(use_debugger=use_debugger, debug=app.debug,302+ use_reloader=use_debugger, host='0.0.0.0')modified:docs/quickstart.rst+3 added-36 removed
75 unmodified lines76 77 This tells your operating system to listen on all public IPs.78 79 80+.. _debug-mode:81+82 Debug Mode83 ----------84 85 The :meth:`~flask.Flask.run` method is nice to start a local27 unmodified lines113 :align: center114 :class: screenshot115 :alt: screenshot of debugger in action116 115-.. admonition:: Working With Other Debuggers117+Have another debugger in mind? See :ref:`working-with-debuggers`.118 117- Debuggers interfere with each other.118- That said, you may still wish to use the debugger in a tool of your choice.119- Flask provides the following options to manage the debug process:119 121- * ``debug`` - whether to enable debug mode and catch exceptinos122- * ``use_debugger`` - whether to use the internal Flask debugger123- * ``use_reloader`` - whether to reload and fork the process on exception124-125- ``debug`` must be True (i.e., exceptions must be caught) in order for the126- other two options to have any value.127-128- If you're using Aptana/Eclipse for debugging you'll need to set both129- ``use_debugger`` and ``use_reloader`` to False.130-131- A possible useful pattern for configuration is to set the following in your132- config.yaml (change the block as approriate for your application, of course)::133-134- FLASK:135- DEBUG: True136- DEBUG_WITH_APTANA: True137-138- Then in your application's entry-point (main.py), you could have something like::139-140- if __name__ == "__main__":141- # To allow aptana to receive errors, set use_debugger=False142- app = create_app(config="config.yaml")143-144- if app.debug: use_debugger = True145- try:146- # Disable Flask's debugger if external debugger is requested147- use_debugger = not(app.config.get('DEBUG_WITH_APTANA'))148- except:149- pass150- app.run(use_debugger=use_debugger, debug=app.debug, use_reloader=use_debugger, host='0.0.0.0')151-152-120 Routing121 -------122 123 Modern web applications have beautiful URLs. This helps people remember705 unmodified lines