Merge changes from topics 'per-output-file', 'stop-processing'

* changes:
  Add syslog template per output file
  Add option to skip the log_collector configuration
  Add stop processing option
diff --git a/README.rst b/README.rst
index 66a93da..7c014b0 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,7 +63,44 @@
               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
 
+Custom templates
+================
+
+It is possible to define a specific syslog template per output file instead of
+using the default one.
+
+.. code-block:: yaml
+
+    rsyslog:
+        output:
+          file:
+           /var/log/your-app.log:
+              template: ""%syslogtag:1:32%%msg:::sp-if-no-1st-sp%%msg%\\n""
+              filter: "if $programname startswith 'your-app' then"
+
+Support metadata
+================
+
+If the *heka* support metadata is enabled, all output files are automatically
+parsed by the **log_collector** service.
+To skip the log_collector configuration, set the **skip_log_collector** to true.
+
+.. code-block:: yaml
+
+    rsyslog:
+        output:
+          file:
+           /var/log/your-app.log:
+              filter: "if $programname startswith 'your-app' then"
+              skip_log_collector: true
 
 Read more
 =========
diff --git a/_modules/rsyslog_util.py b/_modules/rsyslog_util.py
index d58a1c4..df21f07 100644
--- a/_modules/rsyslog_util.py
+++ b/_modules/rsyslog_util.py
@@ -15,7 +15,7 @@
     """
     file_match = {}
     for name, config in output.get('file', {}).items():
-        if not config.get('enabled', False):
+        if not config.get('enabled') or config.get('skip_log_collector', False):
             continue
         logdir = os.path.dirname(name)
         pattern = os.path.basename(name).replace('.', '\.')
diff --git a/rsyslog/files/rsyslog.default.conf b/rsyslog/files/rsyslog.default.conf
index 2e1e3e2..ff7f917 100644
--- a/rsyslog/files/rsyslog.default.conf
+++ b/rsyslog/files/rsyslog.default.conf
@@ -42,7 +42,24 @@
 {# 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 -%}
+{%- if config.template is defined %}
+$Template {{ name|replace('/', '_') }}, "{{ config.template }}"
+{%- endif -%}
+{%- endfor -%}
+
+{%- macro rsyslog_output_file(files) -%}
+{%- for name, config in files.items() %}
 {% if config.owner is defined -%}
 $FileOwner {{ config['owner'] }}
 {% endif -%}
@@ -55,8 +72,15 @@
 {% if config.umask is defined -%}
 $Umask {{ config['umask'] }}
 {% endif -%}
-{{ config['filter'] }}     {% if config.sync == true %}-{% endif %}{{ name }}
+{{ config['filter'] }}     {% if config.sync == true %}-{% endif %}{{ name }}{%if config.template is defined %};{{ name|replace('/', '_') }}{% endif %}
+{%- 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) -%}