Skip to content

Commit 24c8e8a

Browse files
committed
Started the new documentation for logbook's integration
1 parent c9df2ec commit 24c8e8a

File tree

6 files changed

+87
-6
lines changed

6 files changed

+87
-6
lines changed

docs/attic/index.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Old Documentation
2+
=================
3+
4+
This part of the documentation contains documents that are no longer
5+
necessary in recent Flask versions because they document deprecated
6+
functionality or changed behaviour. We keep it around for a certain
7+
period of time because it is still relevant if you relay on this
8+
deprecated functionality.
9+
10+
You are however encouraged to upgrade your application to no longer
11+
depend on this behaviour.
12+
13+
.. toctree::
14+
15+
logging

docs/errorhandling.rst renamed to docs/attic/logging.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
.. _application-errors:
1+
.. _old-logging:
22

3-
Handling Application Errors
4-
===========================
3+
Setting up the old Logging System
4+
=================================
55

66
.. versionadded:: 0.3
77

8+
.. admonition:: Pending Deprecation
9+
10+
This document specifies soon to be deprecated functionality that will
11+
be removed in Flask 1.0. Please have a look at the new :ref:`logging`
12+
documentation instead.
13+
814
Applications fail, servers fail. Sooner or later you will see an exception
915
in production. Even if your code is 100% correct, you will still see
1016
exceptions from time to time. Why? Because everything else involved will

docs/contents.rst.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ instructions for web development with Flask.
1414
tutorial/index
1515
templating
1616
testing
17-
errorhandling
17+
logging
1818
config
1919
signals
2020
shell
@@ -41,6 +41,7 @@ Design notes, legal information and changelog are here for the interested.
4141
.. toctree::
4242
:maxdepth: 2
4343
44+
attic/index
4445
design
4546
htmlfaq
4647
security

docs/logging.rst

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
.. _logging:
2+
3+
Logging and Errorhandling
4+
=========================
5+
6+
.. versionadded:: 0.7
7+
8+
Applications fail, servers fail. Sooner or later you will see an exception
9+
in production. Even if your code is 100% correct, you will still see
10+
exceptions from time to time. Why? Because everything else involved will
11+
fail. Here some situations where perfectly fine code can lead to server
12+
errors:
13+
14+
- the client terminated the request early and the application was still
15+
reading from the incoming data.
16+
- the database server was overloaded and could not handle the query.
17+
- a filesystem is full
18+
- a harddrive crashed
19+
- a backend server overloaded
20+
- a programming error in a library you are using
21+
- network connection of the server to another system failed.
22+
23+
And that's just a small sample of issues you could be facing. So how do we
24+
deal with that sort of problem? By default if your application runs in
25+
production mode, Flask will display a very simple page for you and log the
26+
exception to the :attr:`~flask.Flask.logger`.
27+
28+
But there is more you can do, and we will cover some better setups to deal
29+
with errors.
30+
31+
The Logging System
32+
------------------
33+
34+
In Flask 0.3 we started off with supporting a clever default configuration
35+
of the :mod:`logging` package that comes with Python. In Flask 0.7 we are
36+
starting to make the switch to a new log system called `Logbook`_.
37+
38+
The default will continue to be the logging module until we hit 1.0 when
39+
we change the default to Logbook. Two versions after that we will remove
40+
the support for logging in general.
41+
42+
Why are we doing that? Unfortunately the logging library in Python was
43+
designed with a different kind of application setup in mind. In web
44+
applications what happens is that a thread usually handles a request and
45+
whatever is happening in this thread until a certain point is considered
46+
"belonging" to the same request. The Python logging library however does
47+
not support the idea of per-thread based configurations. Instead it is
48+
using a global registry of loggers which does not translate well to an
49+
application setup.
50+
51+
The way logbook works is that it keeps per-thread configurations of your
52+
logging system which gives you the ability to better customize the
53+
behaviour of the system and provides better means of debugging.
54+
55+
This document only specifies a logbook setup. If you are interested in
56+
the documentation for the old logging system, have a look at
57+
:ref:`old-logging`.
58+
59+
.. _Logbook: http://logbook.pocoo.org/

docs/patterns/errorpages.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ even if the application behaves correctly:
3939
Usually happens on programming errors or if the server is overloaded.
4040
A terrible good idea to have a nice page there, because your
4141
application *will* fail sooner or later (see also:
42-
:ref:`application-errors`).
42+
:ref:`old-logging`).
4343

4444

4545
Error Handlers

docs/upgrading.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ If you run your application in production and want to profit from
125125
automatic error logging, you might be interested in attaching a proper log
126126
handler. Also you can start logging warnings and errors into the logger
127127
when appropriately. For more information on that, read
128-
:ref:`application-errors`.
128+
:ref:`old-logging`.
129129

130130
Categories for Flash Messages
131131
`````````````````````````````

0 commit comments

Comments
 (0)