Added option to enable additional loggers
Fixes PROD-34686
Change-Id: Ibda9460e6fe1a0a2b6a504a7a9834ca17dde7c2b
diff --git a/oslo_templates/files/logging/_logging.conf b/oslo_templates/files/logging/_logging.conf
index 3da84c0..ecbc0e8 100644
--- a/oslo_templates/files/logging/_logging.conf
+++ b/oslo_templates/files/logging/_logging.conf
@@ -1,13 +1,20 @@
{%- set log_handlers = [] -%}
{%- set app_name = _data.app_name -%}
-{%- for log_handler_name, log_handler_attrs in _data.log_handlers.items() %}
+{%- for log_handler_name, log_handler_attrs in _data.get('log_handlers', {}).iteritems() %}
{%- if log_handler_attrs.get('enabled', False) %}
{%- do log_handlers.append(log_handler_name) -%}
{%- endif %}
{%- endfor %}
+{%- set loggers = ["root", app_name] -%}
+{%- for _logger_name, _logger_attrs in _data.get('loggers', {}).iteritems() %}
+ {%- if _logger_attrs.get('enabled', False) and _logger_name not in loggers %}
+ {%- do loggers.append(_logger_name) -%}
+ {%- endif %}
+{%- endfor %}
+
[loggers]
-keys = root, {{ app_name }}
+keys = {{ loggers | join(", ") }}
[handlers]
keys = {{ log_handlers | join(", ") }}