Merge "Expose use_json logging option"
This commit is contained in:
commit
9bf77438df
|
@ -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 ec2api::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/ec2api',
|
||||
|
@ -118,6 +123,7 @@ class ec2api::logging(
|
|||
oslo::log { 'ec2api_config':
|
||||
use_stderr => $use_stderr,
|
||||
use_syslog => $use_syslog,
|
||||
use_json => $use_json,
|
||||
log_dir => $log_dir,
|
||||
log_file => $log_file,
|
||||
debug => $debug,
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
Expose use_json logging parameter, which enables JSON formatted logging.
|
|
@ -1,41 +1,130 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'ec2api::logging' do
|
||||
on_supported_os(supported_os: OSDefaults.get_supported_os).each do |os, facts|
|
||||
|
||||
let :params do
|
||||
{
|
||||
}
|
||||
end
|
||||
|
||||
let :log_params do
|
||||
{
|
||||
:logging_context_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s',
|
||||
:logging_default_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s',
|
||||
:logging_debug_format_suffix => '%(funcName)s %(pathname)s:%(lineno)d',
|
||||
:logging_exception_prefix => '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s',
|
||||
:log_config_append => '/etc/ec2api/logging.conf',
|
||||
:publish_errors => true,
|
||||
:default_log_levels => {
|
||||
'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
|
||||
'sqlalchemy' => 'WARN', 'suds' => 'INFO', 'iso8601' => 'WARN',
|
||||
'requests.packages.urllib3.connectionpool' => 'WARN' },
|
||||
:fatal_deprecations => true,
|
||||
:instance_format => '[instance: %(uuid)s] ',
|
||||
: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',
|
||||
:log_file => '/var/tmp/ec2api_random.log',
|
||||
:debug => true,
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'ec2api-logging' do
|
||||
|
||||
context 'with basic logging options and default settings' do
|
||||
it_configures 'basic default logging settings'
|
||||
end
|
||||
|
||||
context 'with basic logging options and non-default settings' do
|
||||
before { params.merge!( log_params ) }
|
||||
it_configures 'basic non-default logging settings'
|
||||
end
|
||||
|
||||
context 'with extended logging options' do
|
||||
before { params.merge!( log_params ) }
|
||||
it_configures 'logging params set'
|
||||
end
|
||||
|
||||
context 'without extended logging options' do
|
||||
it_configures 'logging params unset'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
shared_examples 'basic default logging settings' do
|
||||
it 'configures ec2api logging settings with default values' do
|
||||
is_expected.to contain_oslo__log('ec2api_config').with(
|
||||
:use_syslog => '<SERVICE DEFAULT>',
|
||||
:use_json => '<SERVICE DEFAULT>',
|
||||
:use_stderr => '<SERVICE DEFAULT>',
|
||||
:syslog_log_facility => '<SERVICE DEFAULT>',
|
||||
:log_dir => '/var/log/ec2api',
|
||||
:log_file => '/var/log/ec2api/ec2api.log',
|
||||
:debug => '<SERVICE DEFAULT>',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'basic non-default logging settings' do
|
||||
it 'configures ec2api logging settings with non-default values' do
|
||||
is_expected.to contain_oslo__log('ec2api_config').with(
|
||||
:use_syslog => true,
|
||||
:use_json => true,
|
||||
:use_stderr => false,
|
||||
:syslog_log_facility => 'LOG_FOO',
|
||||
:log_dir => '/var/log',
|
||||
:log_file => '/var/tmp/ec2api_random.log',
|
||||
:debug => true,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'logging params set' do
|
||||
it 'enables logging params' do
|
||||
is_expected.to contain_oslo__log('ec2api_config').with(
|
||||
:logging_context_format_string =>
|
||||
'%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s',
|
||||
:logging_default_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s',
|
||||
:logging_debug_format_suffix => '%(funcName)s %(pathname)s:%(lineno)d',
|
||||
:logging_exception_prefix => '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s',
|
||||
:log_config_append => '/etc/ec2api/logging.conf',
|
||||
:publish_errors => true,
|
||||
:default_log_levels => {
|
||||
'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
|
||||
'sqlalchemy' => 'WARN', 'suds' => 'INFO', 'iso8601' => 'WARN',
|
||||
'requests.packages.urllib3.connectionpool' => 'WARN' },
|
||||
:fatal_deprecations => true,
|
||||
:instance_format => '[instance: %(uuid)s] ',
|
||||
:instance_uuid_format => '[instance: %(uuid)s] ',
|
||||
:log_date_format => '%Y-%m-%d %H:%M:%S',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'logging params unset' do
|
||||
[ :logging_context_format_string, :logging_default_format_string,
|
||||
:logging_debug_format_suffix, :logging_exception_prefix,
|
||||
:log_config_append, :publish_errors,
|
||||
:default_log_levels, :fatal_deprecations,
|
||||
:instance_format, :instance_uuid_format,
|
||||
:log_date_format, ].each { |param|
|
||||
it { is_expected.to contain_oslo__log('ec2api_config').with("#{param}" => '<SERVICE DEFAULT>') }
|
||||
}
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
|
||||
let(:facts) { facts.merge! @default_facts }
|
||||
|
||||
describe 'with default parameters' do
|
||||
it { is_expected.to compile.with_all_deps }
|
||||
|
||||
it { is_expected.to contain_class('ec2api::logging') }
|
||||
|
||||
parameters = {
|
||||
:use_stderr => '<SERVICE DEFAULT>',
|
||||
:use_syslog => '<SERVICE DEFAULT>',
|
||||
:log_dir => '/var/log/ec2api',
|
||||
:log_file => '/var/log/ec2api/ec2api.log',
|
||||
:debug => '<SERVICE DEFAULT>',
|
||||
:logging_context_format_string => '<SERVICE DEFAULT>',
|
||||
:logging_default_format_string => '<SERVICE DEFAULT>',
|
||||
:logging_debug_format_suffix => '<SERVICE DEFAULT>',
|
||||
:logging_exception_prefix => '<SERVICE DEFAULT>',
|
||||
:log_config_append => '<SERVICE DEFAULT>',
|
||||
:default_log_levels => '<SERVICE DEFAULT>',
|
||||
:publish_errors => '<SERVICE DEFAULT>',
|
||||
:fatal_deprecations => '<SERVICE DEFAULT>',
|
||||
:instance_format => '<SERVICE DEFAULT>',
|
||||
:instance_uuid_format => '<SERVICE DEFAULT>',
|
||||
:log_date_format => '<SERVICE DEFAULT>',
|
||||
:syslog_log_facility => '<SERVICE DEFAULT>',
|
||||
:watch_log_file => '<SERVICE DEFAULT>',
|
||||
:logging_user_identity_format => '<SERVICE DEFAULT>',
|
||||
}
|
||||
|
||||
it { is_expected.to contain_oslo__log('ec2api_config').with(parameters) }
|
||||
let (:facts) do
|
||||
facts.merge!(OSDefaults.get_facts())
|
||||
end
|
||||
|
||||
it_behaves_like 'ec2api-logging'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue