########################################################################
# File managed by Salt at <{{ source }}>.
# Your changes will be overwritten.
########################################################################

{%- from "syslog_ng/macro.jinja" import rule_builder %}

@version: {{ syslog_ng.get('version', '3.3') }}

{%- for module in syslog_ng.get('module', []) %}
@module {{ rule_builder(module) }}
{%- endfor %}

{%- for inc in syslog_ng.get('include', []) %}
@include {{ rule_builder(inc) }}
{%- endfor %}

options {
{%- for rule in syslog_ng.get('options', []) %}
  {{ rule_builder(rule) }};
{%- endfor %}
};

{%- for obj in ('source', 'destination', 'filter', 'parser', 'rewrite', 'template') %}
{%- for params in syslog_ng.get(obj, []) %}
{% for name, rules in params.items() %}
{{ obj }} {{ name }} {
  {%- for rule in rules %}
  {{ rule_builder(rule) }};
  {%- endfor %}
};
{%- endfor %}
{%- endfor %}
{%- endfor %}

{% for loggers in syslog_ng.get('log', []) -%}
log {
  {%- for rule in loggers %}
  {{ rule_builder(rule) }};
  {%- endfor %}
};

{% endfor %}

{%- for inc in syslog_ng.get('last_include', []) %}
@include {{ rule_builder(inc) }}
{%- endfor %}