Book Image

Learning Flask Framework

Book Image

Learning Flask Framework

Overview of this book

Table of Contents (17 chapters)
Learning Flask Framework
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Logging and error reporting


Logging and error reporting are intrinsic to a production-ready web app. Logging keeps a record of all problems even if your app has crashed, while error reporting can directly notify us of specific problems even though the site keeps running.

It can be very gratifying to discover errors before anyone has reported them. It also makes it possible to roll out fixes before your users start complaining to you. However, to do this, you need to know what those errors were, when they occurred, and what caused them.

Fortunately, as must be quite familiar right now, Python and Flask already have this in hand.

Logging

Flask comes with a built-in logger—an already defined instance of Python's built-in logger. You will hopefully be quite familiar with it by now. The logger messages are displayed, by default, each time a page is accessed.

The preceding screenshot, obviously, shows the output to the terminal. We can see here that someone accessed the root page from localhost (127...