From 0dce6fcd0f9e7d08199912045e3bc33f0b146024 Mon Sep 17 00:00:00 2001 From: "archie.harris" Date: Fri, 27 Nov 2015 13:23:45 +1100 Subject: [PATCH 1/4] feature/manage-logging-options - add logger.conf.erb template for logging options --- templates/logger.conf.erb | 177 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 templates/logger.conf.erb diff --git a/templates/logger.conf.erb b/templates/logger.conf.erb new file mode 100644 index 0000000..5cab364 --- /dev/null +++ b/templates/logger.conf.erb @@ -0,0 +1,177 @@ +; +; Logging Configuration +; +; In this file, you configure logging to files or to +; the syslog system. +; +; "logger reload" at the CLI will reload configuration +; of the logging system. + +[general] +; +; Customize the display of debug message time stamps +; this example is the ISO 8601 date format (yyyy-mm-dd HH:MM:SS) +; +; see strftime(3) Linux manual for format specifiers. Note that there is also +; a fractional second parameter which may be used in this field. Use %1q +; for tenths, %2q for hundredths, etc. +; +;dateformat=%F %T ; ISO 8601 date format +;dateformat=%F %T.%3q ; with milliseconds +; +; +; This makes Asterisk write callids to log messages +; (defaults to yes) +;use_callids = no +; +; This appends the hostname to the name of the log files. +;appendhostname = yes +; +; This determines whether or not we log queue events to a file +; (defaults to yes). +;queue_log = no +; +; Determines whether the queue_log always goes to a file, even +; when a realtime backend is present (defaults to no). +;queue_log_to_file = yes +; +; Set the queue_log filename +; (defaults to queue_log) +;queue_log_name = queue_log + +; When using realtime for the queue log, use GMT for the timestamp +; instead of localtime. (defaults to no) +;queue_log_realtime_use_gmt = no + +; Log rotation strategy (defaults to sequential): +; none: Do not perform any log rotation at all. You should make +; very sure to set up some external log rotate mechanism +; as the asterisk logs can get very large, very quickly. +; sequential: Rename archived logs in order, such that the newest +; has the highest sequence number. When +; exec_after_rotate is set, ${filename} will specify +; the new archived logfile. +; rotate: Rotate all the old files, such that the oldest has the +; highest sequence number [this is the expected behavior +; for Unix administrators]. When exec_after_rotate is +; set, ${filename} will specify the original root filename. +; timestamp: Rename the logfiles using a timestamp instead of a +; sequence number when "logger rotate" is executed. +; When exec_after_rotate is set, ${filename} will +; specify the new archived logfile. +;rotatestrategy = rotate +; +; Run a system command after rotating the files. This is mainly +; useful for rotatestrategy=rotate. The example allows the last +; two archive files to remain uncompressed, but after that point, +; they are compressed on disk. +; +; exec_after_rotate=gzip -9 ${filename}.2 +; +; +[logfiles] +; For each file, specify what to log. +; +; For console logging, you set options at start of +; Asterisk with -v for verbose and -d for debug +; See 'asterisk -h' for more information. +; +; Directory for log files is configures in asterisk.conf +; option astlogdir +; +; File names can either be relative to the standard Asterisk log directory (see "astlogdir" in +; asterisk.conf), or absolute paths that begin with '/'. +; +; A few file names have been reserved and are considered special, thus cannot be used and will +; not be considered as a regular file name. These include the following: +; +; syslog - logs to syslog facility +; console - logs messages to the Asterisk root console. +; +; Format is "filename" and then "levels" of debugging to be included. +; For each file name given a comma separated list of logging "level" types should be specified +; and include at least one of the following (in no particular order): +; debug +; notice +; warning +; error +; verbose() +; dtmf +; fax +; security +; +; The "verbose" value can take an optional integer argument that indicates the maximum level +; of verbosity to log at. Verbose messages with higher levels than the indicated level will +; not be logged to the file. If a verbose level is not given, verbose messages are logged +; based upon the current level set for the root console. + +; Special filename "console" represents the root console +; +; +; Verbose takes an optional argument, in the form of an integer level. +; Verbose messages with higher levels will not be logged to the file. If +; the verbose level is not specified, it will log verbose messages following +; the current level of the root console. +; +; The special character "*" can also be specified and represents all levels, even dynamic +; levels registered by modules after the logger has been initialized. This means that loading +; and unloading modules that create and remove dynamic logging levels will result in these +; levels being included on filenames that have a level name of "*", without any need to +; perform a "logger reload" or similar operation. +; +; Special level name "*" means all levels, even dynamic levels registered +; by modules after the logger has been initialized (this means that loading +; and unloading modules that create/remove dynamic logger levels will result +; in these levels being included on filenames that have a level name of "*", +; without any need to perform a 'logger reload' or similar operation). +; Note that there is no value in specifying both "*" and specific level names +; for a filename; the "*" level means all levels. The only exception is if +; you need to specify a specific verbose level. e.g, "verbose(3),*". +; +; Note, there is no value in specifying both "*" and specific level types for a file name. +; The "*" level means ALL levels. The only exception is if you need to specify a specific +; verbose level. e.g, "verbose(3),*". +; +; We highly recommend that you DO NOT turn on debug mode if you are simply +; running a production system. Debug mode turns on a LOT of extra messages, +; most of which you are unlikely to understand without an understanding of +; the underlying code. Do NOT report debug messages as code issues, unless +; you have a specific issue that you are attempting to debug. They are +; messages for just that -- debugging -- and do not rise to the level of +; something that merit your attention as an Asterisk administrator. Debug +; messages are also very verbose and can and do fill up logfiles quickly; +; this is another reason not to have debug mode on a production system unless +; you are in the process of debugging a specific issue. +; +; It is highly recommended that you DO NOT turn on debug mode when running a production system +; unless you are in the process of debugging a specific issue. Debug mode outputs a LOT of +; extra messages and information that can and do fill up log files quickly. Most of these +; messages are hard to interpret without an understanding of the underlying code. Do NOT report +; debug messages as code issues, unless you have a specific issue that you are attempting to debug. +; They are messages for just that -- debugging -- and do not rise to the level of something that +; merit your attention as an Asterisk administrator. +; +; output notices, warnings and errors to the console +;console => notice,warning,error +; +; output security messages to the file named "security" +;security => security +; +; output notices, warnings and errors to the the file named "messages" +;messages => notice,warning,error +; +; output notices, warnings, errors, verbose, dtmf, and fax to file name "full" +;full => notice,warning,error,verbose,dtmf,fax +; +; output notices, warning, and errors to the syslog facility +;syslog.local0 => notice,warning,error +; +;debug => debug +;security => security +;console => notice,warning,error +;console => notice,warning,error,debug +;messages => notice,warning,error +;full => notice,warning,error,debug,verbose,dtmf,fax + +;syslog keyword : This special keyword logs to syslog facility +;syslog.local0 => notice,warning,error From cefadf335972d000796e02c00f2d4f181f5416ef Mon Sep 17 00:00:00 2001 From: "archie.harris" Date: Fri, 27 Nov 2015 13:27:19 +1100 Subject: [PATCH 2/4] feature/manage-logging-options - add logger_options defaults to params.pp --- manifests/params.pp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/manifests/params.pp b/manifests/params.pp index a129919..dfa4f56 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -72,6 +72,13 @@ 'monitor-type' => 'MixMonitor', } + $logger_options = { + 'rotatestrategy' => 'rotate', + 'use_callids' => 'yes', + 'appendhostname' => 'yes', + 'queue_log' => 'yes', + } + $modules_autoload = true $modules_noload = [ 'pbx_gtkconsole.so', From 9c476da4a56b1fcce422b3a43278c9c5fb9d29e8 Mon Sep 17 00:00:00 2001 From: "archie.harris" Date: Fri, 27 Nov 2015 13:30:54 +1100 Subject: [PATCH 3/4] feature/manage-logging-options - add asterisk::dotd resource for logger_options config file --- manifests/config.pp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/manifests/config.pp b/manifests/config.pp index 7f08e18..18d8973 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -59,6 +59,11 @@ content => template('asterisk/queues.conf.erb'), } + $logger_options = $asterisk::logger_options + asterisk::dotd { '/etc/asterisk/logger': + content => template('asterisk/logger.conf.erb'), + } + $manager_enable = $asterisk::real_manager_enable $manager_port = $asterisk::manager_port $manager_bindaddr = $asterisk::manager_bindaddr From 0b277260d832cd7de3fc3c9360b1ab23862353fc Mon Sep 17 00:00:00 2001 From: "archie.harris" Date: Fri, 27 Nov 2015 15:05:13 +1100 Subject: [PATCH 4/4] feature/manage-logging-options - add logger_options parameter to init.pp - modify logger.conf.erb template to interpolate logger_options - add default log file and level mappings to logger.conf.erb template --- manifests/init.pp | 2 ++ templates/logger.conf.erb | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 558638d..abd2ad8 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -17,6 +17,7 @@ $agents_options = {}, $features_options = $asterisk::params::features_options, $features_featuremap = {}, + $logger_options = $asterisk::params::logger_options, $queues_options = {}, $modules_autoload = $asterisk::params::modules_autoload, $modules_noload = $asterisk::params::modules_noload, @@ -37,6 +38,7 @@ validate_hash($agents_options) validate_hash($features_options) validate_hash($features_featuremap) + validate_hash($logger_options) validate_hash($queues_options) validate_bool($modules_autoload) validate_array($modules_noload) diff --git a/templates/logger.conf.erb b/templates/logger.conf.erb index 5cab364..dadd2e5 100644 --- a/templates/logger.conf.erb +++ b/templates/logger.conf.erb @@ -6,8 +6,8 @@ ; ; "logger reload" at the CLI will reload configuration ; of the logging system. - -[general] +; +;[general] ; ; Customize the display of debug message time stamps ; this example is the ISO 8601 date format (yyyy-mm-dd HH:MM:SS) @@ -175,3 +175,21 @@ ;syslog keyword : This special keyword logs to syslog facility ;syslog.local0 => notice,warning,error + +[general] +<% @logger_options.sort.map do |name, value| + if value.is_a? Array + value.each do |v| -%> +<%= name -%>=<%= v %> +<% end + else -%> +<%= name -%>=<%= value %> +<% end +end -%> + +[logfiles] +console => notice,warning,error,security +messages => notice,warning,error,security + +#include +