Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
72 lines (54 sloc) 3 KB

Configuration

Settings

Qval supports configuration via config files and environmental variables. If DJANGO_SETTINGS_MODULE or SETTINGS_MODULE are defined, the specified config module will be used. Otherwise, all lookups would be done in :obj:`os.environ`.

Supported variables:

Logging

Qval uses a global :obj:`log <qval.utils.log>` object acting as singleton when reporting errors. By default, :func:`logging.getLogger` function is used as a factory on each call. You can provide your own factory (see Settings) or disable the logging. Example error message:

An error occurred during the validation or inside of the context: exc `<class 'OverflowError'>` ((34, 'Numerical result out of range')).
| Parameters: <QueryDict: {'a': ['2.2324'], 'b': ['30000000']}>
| Body      : b''
| Exception:
Traceback (most recent call last):
  File "<path>/qval/qval.py", line 338, in inner
    return f(*args, params, **kwargs)
  File "<path>/examples/django-example/app/views.py", line 46, in pow_view
    return JsonResponse({"answer": params.a ** params.b})
OverflowError: (34, 'Numerical result out of range')
Internal Server Error: /api/pow
[19/Nov/2018 07:03:15] "GET /api/pow?a=2.2324&b=30000000 HTTP/1.1" 500 102

Import the :obj:`log <qval.utils.log>` object from :mod:`qval.utils` and configure as you need:

from qval import log
# For instance, disable logging:
log.disable()
You can’t perform that action at this time.