Expose use_json logging option

It enables JSON-formatted logging from oslo.log.

Change-Id: I0a01c3b3cd8159a164d45ecddf52d028bbcef1c3
This commit is contained in:
ZhongShengping 2017-11-28 09:30:28 +08:00
parent 1c2813918b
commit 05276d9758
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
@ -91,6 +95,7 @@
#
class magnum::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/magnum',
@ -113,6 +118,7 @@ class magnum::logging(
oslo::log { 'magnum_config':
debug => $debug,
use_syslog => $use_syslog,
use_json => $use_json,
use_stderr => $use_stderr,
log_dir => $log_dir,
syslog_log_facility => $log_facility,

View File

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

View File

@ -24,6 +24,7 @@ describe 'magnum::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',
@ -56,6 +57,7 @@ describe 'magnum::logging' do
shared_examples 'basic default logging settings' do
it 'configures magnum logging settings with default values' do
is_expected.to contain_magnum_config('DEFAULT/use_syslog').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_magnum_config('DEFAULT/use_json').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_magnum_config('DEFAULT/use_stderr').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_magnum_config('DEFAULT/syslog_log_facility').with(:value => '<SERVICE DEFAULT>')
is_expected.to contain_magnum_config('DEFAULT/log_dir').with(:value => '/var/log/magnum')
@ -66,6 +68,7 @@ describe 'magnum::logging' do
shared_examples 'basic non-default logging settings' do
it 'configures magnum logging settings with non-default values' do
is_expected.to contain_magnum_config('DEFAULT/use_syslog').with(:value => 'true')
is_expected.to contain_magnum_config('DEFAULT/use_json').with(:value => 'true')
is_expected.to contain_magnum_config('DEFAULT/use_stderr').with(:value => 'false')
is_expected.to contain_magnum_config('DEFAULT/syslog_log_facility').with(:value => 'LOG_FOO')
is_expected.to contain_magnum_config('DEFAULT/log_dir').with(:value => '/var/log')