Expose use_json logging option

It enables JSON-formatted logging from oslo.log.

Change-Id: I9a1b4f43826d060c56af6d42900da5e26060bc8a
This commit is contained in:
Juan Antonio Osorio Robles 2017-11-27 14:58:40 +02:00
parent e14524a2cf
commit c5d0c3ec34
3 changed files with 13 additions and 0 deletions

View File

@ -12,6 +12,10 @@
# (Optional) Use syslog for logging.
# Defaults to $::os_service_default
#
# [*use_json*]
# (Optional) Use json for logging.
# Defaults to $::os_service_default
#
# [*use_stderr*]
# (optional) Use stderr for logging
# Defaults to $::os_service_default
@ -95,6 +99,7 @@
#
class barbican::api::logging(
$use_syslog = $::os_service_default,
$use_json = $::os_service_default,
$use_stderr = $::os_service_default,
$log_facility = $::os_service_default,
$log_dir = '/var/log/barbican',
@ -118,6 +123,7 @@ class barbican::api::logging(
oslo::log { 'barbican_config':
debug => $debug,
use_syslog => $use_syslog,
use_json => $use_json,
use_stderr => $use_stderr,
log_dir => $log_dir,
log_file => $log_file,

View File

@ -0,0 +1,4 @@
---
features:
- |
Expose use_json logging parameter, which enables JSON formatted logging.

View File

@ -43,6 +43,7 @@ describe 'barbican::api::logging' do
:instance_uuid_format => '[instance: %(uuid)s] ',
:log_date_format => '%Y-%m-%d %H:%M:%S',
:use_syslog => true,
:use_json => true,
:use_stderr => false,
:log_facility => 'LOG_FOO',
:log_dir => '/var/log',
@ -77,6 +78,7 @@ describe 'barbican::api::logging' do
it 'configures barbican logging settings with default values' do
is_expected.to contain_oslo__log('barbican_config').with(
:use_syslog => '<SERVICE DEFAULT>',
:use_json => '<SERVICE DEFAULT>',
:use_stderr => '<SERVICE DEFAULT>',
:syslog_log_facility => '<SERVICE DEFAULT>',
:log_dir => '/var/log/barbican',
@ -90,6 +92,7 @@ describe 'barbican::api::logging' do
it 'configures barbican logging settings with non-default values' do
is_expected.to contain_oslo__log('barbican_config').with(
:use_syslog => true,
:use_json => true,
:use_stderr => false,
:syslog_log_facility => 'LOG_FOO',
:log_dir => '/var/log',