File: logging.rst

package info (click to toggle)
quart 0.20.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,888 kB
  • sloc: python: 8,644; makefile: 42; sh: 17; sql: 6
file content (47 lines) | stat: -rw-r--r-- 1,097 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
.. _how_to_log:

Logging
=======

Quart has a standard Python logger sharing the same name as the
``app.name``. To use it, simply make use of
:attr:`~quart.app.Quart.logger`, for example:

.. code-block:: python

    app.logger.info('Interesting')
    app.logger.warning('Easy Now')

Configuration
-------------

The Quart logger is not created until its first usage, which may occur
as the app is created. These loggers on creation respect any existing
configuration. This allows the loggers to be configured like any other
python logger, for example

.. code-block:: python

    from logging.config import dictConfig

    dictConfig({
        'version': 1,
        'loggers': {
            'quart.app': {
                'level': 'ERROR',
            },
        },
    })

Disabling/removing handlers
---------------------------

The handler :attr:`~quart.logging.default_handler` attached to the
quart logger can be removed like so,

.. code-block:: python

    from logging import getLogger
    from quart.logging import default_handler

    getLogger(app.name).removeHandler(default_handler)