Add stop processing option

This allows to use dedicated log files for some services. This is
especially useful when journald is around and forward logs to syslog.

Change-Id: I1edb2300d9596350567ba766a1b87cf6cd88aedb
diff --git a/README.rst b/README.rst
index 66a93da..c1126d4 100644
--- a/README.rst
+++ b/README.rst
@@ -27,7 +27,7 @@
         format:
           name: TraditionalFormatWithPRI
           template: '"%syslogpriority% %syslogfacility% %timestamp:::date-rfc3339% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"'
-        logfiles:
+        output:
           file:
             -/var/log/syslog:
               filter: *.*;auth,authpriv.none
@@ -63,6 +63,13 @@
               filter: *.emerg
             "|/dev/xconsole":
               filter: "daemon.*;mail.*; news.err; *.=debug;*.=info;*.=notice;*.=warn":
+           -/var/log/your-app.log:
+              filter: "if $programname startswith 'your-app' then"
+              owner: syslog
+              group: adm
+              createmode: 0640
+              umask: 0022
+              stop_processing: true
 
 
 Read more
diff --git a/rsyslog/files/rsyslog.default.conf b/rsyslog/files/rsyslog.default.conf
index 2e1e3e2..dd02b5d 100644
--- a/rsyslog/files/rsyslog.default.conf
+++ b/rsyslog/files/rsyslog.default.conf
@@ -42,7 +42,21 @@
 {# Additional configurations should be included after defining the global format otherwise they won't benefit from it #}
 $IncludeConfig {{ global.rsyslog_d }}/*.conf
 
-{% for name,config in global.output.file.iteritems() if config.get('enabled', False) %}
+{%- set file_groups = {
+  'stop': {},
+  'other': {}
+} -%}
+
+{%- for name,config in global.output.file.iteritems() if config.get('enabled', False) %}
+{%- if config.get('stop_processing', False) -%}
+{%- do file_groups.stop.update({name: config}) -%}
+{%- else -%}
+{%- do file_groups.other.update({name: config}) -%}
+{%- endif -%}
+{%- endfor -%}
+
+{%- macro rsyslog_output_file(files) -%}
+{%- for name, config in files.items() %}
 {% if config.owner is defined -%}
 $FileOwner {{ config['owner'] }}
 {% endif -%}
@@ -56,7 +70,14 @@
 $Umask {{ config['umask'] }}
 {% endif -%}
 {{ config['filter'] }}     {% if config.sync == true %}-{% endif %}{{ name }}
+{%- if config.get('stop_processing', False) %}
+&stop
+{%- endif %}
 {% endfor -%}
+{%- endmacro %}
+
+{{ rsyslog_output_file(file_groups.stop) }}
+{{ rsyslog_output_file(file_groups.other) }}
 
 {% if global.output.console is defined %}
 {% for name,config in global.output.console.iteritems() if config.get('enabled', False) -%}