Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dev-2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcs committed Oct 29, 2018
2 parents 0545ad1 + 08faf2a commit 920f13d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
34 changes: 34 additions & 0 deletions docs/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,37 @@ to set CORS headers:
.. _CORS: https://en.wikipedia.org/wiki/Cross-origin_resource_sharing
.. _flask-cors: https://flask-cors.readthedocs.io/


Logging
------------

You can customize logging accessing the `_flask-logger` directly
or configuring the logger via dictConfig.
Remember that you should configure logging for your project as soon
as possible when the program starts or you'll get the default configuration.

.. code-block:: python
import connexion
from logging.config import dictConfig
dictConfig({
'version': 1,
'handlers': {
'syslog': {
'class': 'logging.handlers.SysLogHandler'
}
},
'root': {
'handlers': ['syslog']
}
})
app = connexion.FlaskApp(__name__)
app.app.logger.warn("I configured the flask logger!")
app.add_api('swagger.yaml')
app.run(port=8080)
.. _flask-logger: http://flask.pocoo.org/docs/1.0/logging/
5 changes: 4 additions & 1 deletion examples/swagger2/sqlalchemy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,7 @@ def shutdown_session(exception=None):


if __name__ == '__main__':
app.run(port=8080)
app.run(
port=8080,
threaded=False # in-memory database isn't shared across threads
)

0 comments on commit 920f13d

Please sign in to comment.