Configuration and Logging
=========================

The configurable settings are stored in a dictionary in `aca_view.config.SETTINGS`.
You can inspect it in the python terminal::

    >>> import aca_view.config
    >>> aca_view.config.SETTINGS['aca_widget']['window_size']
    16

and you can edit, save it:

    >>> import aca_view.config
    >>> aca_view.config.SETTINGS['aca_widget']['window_size'] = 14
    >>> aca_view.config.SETTINGS.save()

and retrieve it in subsequent sessions:

    >>> import aca_view.config
    >>> aca_view.config.SETTINGS['aca_widget']['window_size']
    14

ACA-view also includes a very simple settings editor.


How to Configure the Logging Module
-----------------------------------

Logging in aca_view grew to enable these two requirements:

- to serialize log messages from child processes into a single log.
- to be able to switch on/off certain messages, depending on the case.

For this reason, configuration is not trivial. To configure the logging module, one follows the
`logging.config module documentation <https://docs.python.org/3/library/logging.config.html>`_. What follows is an
elaborate configuration which includes logging configuration. I have used it to log function execution times.
It differs from the default in the following:

- specifies a formatter, called 'time', that will be used to write log entries in a way that is easy to parse,
- creates a logging.FileHandler, called 'time', to keep the log messages from the timing loggers,
- it sets the log level of the aca_view logger to DEBUG
- it sets the log level of all descendants (aca_view.*) to WARNING, except aca_view.timing which is se to DEBUG
- set the handler of the aca_view.timing logger to 'time'.

.. literalinclude:: files/logging_config.json
  :language: JSON

API
---

.. automodule:: aca_view.config
   :members: