Skip to content
Myr

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

2 files+70 added−38 removed

modified:docs/errorhandling.rst+67 added-2 removed
1.. _application-errors:23Handling Application Errors4===========================3Logging Application Errors4==========================56.. versionadded:: 0.378Applications fail, servers fail. Sooner or later you will see an exception
225 unmodified lines
234 getLogger('otherlibrary')]235 for logger in loggers:236 logger.addHandler(mail_handler)237 logger.addHandler(file_handler)238239240Debugging Application Errors241============================242243For production applications, configure your application with logging and244notifications as described in :ref:`application-errors`. This section provides245pointers when debugging deployment configuration and digging deeper with a246full-featured Python debugger.247248249When in Doubt, Run Manually250---------------------------251252Having problems getting your application configured for production? If you253have shell access to your host, verify that you can run your application254manually from the shell in the deployment environment. Be sure to run under255the same user account as the configured deployment to troubleshoot permission256issues. You can use Flask's builtin development server with `debug=True` on257your production host, which is helpful in catching configuration issues, but258**be sure to do this temporarily in a controlled environment.** Do not run in259production with `debug=True`.260261262.. _working-with-debuggers:263264Working with Debuggers265----------------------266267To dig deeper, possibly to trace code execution, Flask provides a debugger out268of the box (see :ref:`debug-mode`). If you would like to use another Python269debugger, note that debuggers interfere with each other. You have to set some270options in order to use your favorite debugger:271272* ``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 exception275276``debug`` must be True (i.e., exceptions must be caught) in order for the other277two options to have any value.278279If you're using Aptana/Eclipse for debugging you'll need to set both280``use_debugger`` and ``use_reloader`` to False.281282A possible useful pattern for configuration is to set the following in your283config.yaml (change the block as approriate for your application, of course)::284285 FLASK:286 DEBUG: True287 DEBUG_WITH_APTANA: True288289Then in your application's entry-point (main.py), you could have something like::290291 if __name__ == "__main__":292 # To allow aptana to receive errors, set use_debugger=False293 app = create_app(config="config.yaml")294295 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 lines
7677 This tells your operating system to listen on all public IPs.787980.. _debug-mode:8182Debug Mode83----------8485The :meth:`~flask.Flask.run` method is nice to start a local
27 unmodified lines
113 :align: center114 :class: screenshot115 :alt: screenshot of debugger in action116115.. admonition:: Working With Other Debuggers117Have another debugger in mind? See :ref:`working-with-debuggers`.118117 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:119121 * ``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 exception124125 ``debug`` must be True (i.e., exceptions must be caught) in order for the126 other two options to have any value.127128 If you're using Aptana/Eclipse for debugging you'll need to set both129 ``use_debugger`` and ``use_reloader`` to False.130131 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)::133134 FLASK:135 DEBUG: True136 DEBUG_WITH_APTANA: True137138 Then in your application's entry-point (main.py), you could have something like::139140 if __name__ == "__main__":141 # To allow aptana to receive errors, set use_debugger=False142 app = create_app(config="config.yaml")143144 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')151152120Routing121-------122123Modern web applications have beautiful URLs. This helps people remember
705 unmodified lines