{% from 'macros/common_macros.lua.j2' import boolean %}

-- logging.level
{% if cfg.logging.groups and "kresd" in cfg.logging.groups %}
log_level('debug')
{% else %}
log_level('{{ cfg.logging.level }}')
{% endif %}

{% if cfg.logging.target -%}
-- logging.target
log_target('{{ cfg.logging.target }}')
{%- endif %}

{% if cfg.logging.groups %}
-- logging.groups
log_groups({
{% for g in cfg.logging.groups %}
{% if g not in [
    "manager", "supervisord", "policy-loader", "kresd", "cache-gc",
    "files", "metrics", "server",
] %}
    '{{ g }}',
{% endif %}
{% endfor %}
})
{% endif %}

{% if cfg.logging.dnstap.enable -%}
-- logging.dnstap
modules.load('dnstap')
dnstap.config({
    socket_path = '{{ cfg.logging.dnstap.unix_socket }}',
    client = {
        log_queries = {{ boolean(cfg.logging.dnstap.log_queries) }},
        log_responses = {{ boolean(cfg.logging.dnstap.log_responses) }},
        log_tcp_rtt = {{ boolean(cfg.logging.dnstap.log_tcp_rtt) }}
    }
})
{%- endif %}
