Add log_file parameter

Change-Id: I1571576dc4c1958c5d1ed9cd7cc594d8a0daa005
This commit is contained in:
Shi Yan 2019-03-06 11:48:26 +11:00 committed by Rocky
parent f6e1ae301d
commit 312338f9c9
3 changed files with 13 additions and 0 deletions

View File

@ -28,6 +28,10 @@
# Syslog facility to receive log lines. # Syslog facility to receive log lines.
# (Optional) Defaults to $::os_service_default. # (Optional) Defaults to $::os_service_default.
# #
# [*log_file*]
# (optional) Where to log
# Defaults to $::os_service_default
#
# [*log_dir*] # [*log_dir*]
# (Optional) Directory where logs should be stored. # (Optional) Directory where logs should be stored.
# If set to $::os_service_default, it will not log to any directory. # If set to $::os_service_default, it will not log to any directory.
@ -100,6 +104,7 @@ class sahara::logging(
$use_journal = $::os_service_default, $use_journal = $::os_service_default,
$use_stderr = $::os_service_default, $use_stderr = $::os_service_default,
$log_facility = $::os_service_default, $log_facility = $::os_service_default,
$log_file = $::os_service_default,
$log_dir = '/var/log/sahara', $log_dir = '/var/log/sahara',
$logging_context_format_string = $::os_service_default, $logging_context_format_string = $::os_service_default,
$logging_default_format_string = $::os_service_default, $logging_default_format_string = $::os_service_default,
@ -122,6 +127,7 @@ class sahara::logging(
use_json => $use_json, use_json => $use_json,
use_journal => $use_journal, use_journal => $use_journal,
use_stderr => $use_stderr, use_stderr => $use_stderr,
log_file => $log_file,
log_dir => $log_dir, log_dir => $log_dir,
syslog_log_facility => $log_facility, syslog_log_facility => $log_facility,
logging_context_format_string => $logging_context_format_string, logging_context_format_string => $logging_context_format_string,

View File

@ -0,0 +1,4 @@
---
features:
- |
Add the log_file option for logging.

View File

@ -15,6 +15,7 @@ describe 'sahara::logging' do
:use_journal => 'true', :use_journal => 'true',
:use_stderr => 'false', :use_stderr => 'false',
:log_facility => 'LOG_LOCAL0', :log_facility => 'LOG_LOCAL0',
:log_file => 'sahara.log',
:log_dir => '/tmp/sahara', :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_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_default_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s',
@ -67,6 +68,7 @@ describe 'sahara::logging' do
:use_json => '<SERVICE DEFAULT>', :use_json => '<SERVICE DEFAULT>',
:use_journal => '<SERVICE DEFAULT>', :use_journal => '<SERVICE DEFAULT>',
:use_stderr => '<SERVICE DEFAULT>', :use_stderr => '<SERVICE DEFAULT>',
:log_file => '<SERVICE DEFAULT>',
:log_dir => '/var/log/sahara', :log_dir => '/var/log/sahara',
:debug => '<SERVICE DEFAULT>', :debug => '<SERVICE DEFAULT>',
)} )}
@ -92,6 +94,7 @@ describe 'sahara::logging' do
:use_journal => true, :use_journal => true,
:use_stderr => false, :use_stderr => false,
:syslog_log_facility => 'LOG_LOCAL0', :syslog_log_facility => 'LOG_LOCAL0',
:log_file => 'sahara.log',
:log_dir => '/tmp/sahara', :log_dir => '/tmp/sahara',
:debug => true, :debug => true,
)} )}