Add watch_log_file option

Add support for Using logging handler designed to watch file system.

Change-Id: I2a29da0f098d3f7aa27708e18905821545ce3fda
Closes-Bug: #1943212
This commit is contained in:
ZhongShengping 2021-09-14 16:02:09 +08:00
parent d51569c7d7
commit 24db636fad
3 changed files with 20 additions and 7 deletions

View File

@ -32,6 +32,10 @@
# (optional) Where to log
# Defaults to $::os_service_default
#
# [*watch_log_file*]
# (Optional) Uses logging handler designed to watch file system (boolean value).
# Defaults to $::os_service_default
#
# [*log_dir*]
# (Optional) Directory where logs should be stored.
# If set to $::os_service_default, it will not log to any directory.
@ -105,6 +109,7 @@ class sahara::logging(
$use_stderr = $::os_service_default,
$log_facility = $::os_service_default,
$log_file = $::os_service_default,
$watch_log_file = $::os_service_default,
$log_dir = '/var/log/sahara',
$logging_context_format_string = $::os_service_default,
$logging_default_format_string = $::os_service_default,
@ -128,6 +133,7 @@ class sahara::logging(
use_journal => $use_journal,
use_stderr => $use_stderr,
log_file => $log_file,
watch_log_file => $watch_log_file,
log_dir => $log_dir,
syslog_log_facility => $log_facility,
logging_context_format_string => $logging_context_format_string,

View File

@ -0,0 +1,4 @@
---
features:
- |
The new ``sahara::logging::watch_log_file`` parameter has been added.

View File

@ -16,6 +16,7 @@ describe 'sahara::logging' do
:use_stderr => 'false',
:log_facility => 'LOG_LOCAL0',
:log_file => 'sahara.log',
:watch_log_file => 'true',
:log_dir => '/tmp/sahara',
: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',
@ -64,13 +65,14 @@ describe 'sahara::logging' do
context 'with defaults' do
it { is_expected.to contain_oslo__log('sahara_config').with(
:use_syslog => '<SERVICE DEFAULT>',
:use_json => '<SERVICE DEFAULT>',
:use_journal => '<SERVICE DEFAULT>',
:use_stderr => '<SERVICE DEFAULT>',
:log_file => '<SERVICE DEFAULT>',
:log_dir => '/var/log/sahara',
:debug => '<SERVICE DEFAULT>',
:use_syslog => '<SERVICE DEFAULT>',
:use_json => '<SERVICE DEFAULT>',
:use_journal => '<SERVICE DEFAULT>',
:use_stderr => '<SERVICE DEFAULT>',
:log_file => '<SERVICE DEFAULT>',
:watch_log_file => '<SERVICE DEFAULT>',
:log_dir => '/var/log/sahara',
:debug => '<SERVICE DEFAULT>',
)}
end
@ -95,6 +97,7 @@ describe 'sahara::logging' do
:use_stderr => false,
:syslog_log_facility => 'LOG_LOCAL0',
:log_file => 'sahara.log',
:watch_log_file => true,
:log_dir => '/tmp/sahara',
:debug => true,
)}