Navigation Menu

Skip to content

Commit

Permalink
fmDNS - Issue #47 - Improved logging channel definitions regarding fi…
Browse files Browse the repository at this point in the history
…le versions and size.
  • Loading branch information
WillyXJ authored and WillyXJ committed Dec 12, 2013
1 parent 7734653 commit 9a09109
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions server/fm-modules/fmDNS/change.log
Expand Up @@ -18,6 +18,8 @@
* Both - Added option to update client configs via SSH.
* Server - Fixed an issue where the timezone was not set correctly for config
builds.
* Server - (Git Issue 47) Improved logging channel definitions regarding file
versions and size.

1.0-rc6 (2013-11-06)
====================
Expand Down
18 changes: 9 additions & 9 deletions server/fm-modules/fmDNS/classes/class_logging.php
Expand Up @@ -77,7 +77,6 @@ function addChannel($post) {

if ($post['cfg_destination'] == 'file') {
if (empty($post['cfg_file_path'][0])) return 'No file path defined.';
if (empty($post['cfg_file_path'][2])) return 'No file size defined.';
}
$exclude = array('submit', 'action', 'cfg_id', 'sub_type', 'temp_data', 'cfg_destination',
'cfg_file_path', 'cfg_syslog', 'severity', 'print-category', 'print-severity',
Expand Down Expand Up @@ -119,7 +118,8 @@ function addChannel($post) {
} elseif ($handler == 'cfg_destination' && $post[$handler] == 'file') {
list($file_path, $file_versions, $file_size, $file_size_spec) = $post['cfg_file_path'];
$filename = str_replace('"', '', $file_path);
$post['cfg_data'] = '"' . $filename . '" versions ' . $file_versions;
$post['cfg_data'] = '"' . $filename . '"';
if ($file_versions) $post['cfg_data'] .= ' versions ' . $file_versions;
if (!empty($file_size) && $file_size > 0) $post['cfg_data'] .= ' size ' . $file_size . $file_size_spec;
}
if ($handler == 'cfg_destination') {
Expand Down Expand Up @@ -235,7 +235,6 @@ function update($post) {
if (empty($post['cfg_name'])) return 'No channel defined.';
if ($post['cfg_destination'] == 'file') {
if (empty($post['cfg_file_path'][0])) return 'No file path defined.';
if (empty($post['cfg_file_path'][2])) return 'No file size defined.';
}
}
if ($post['sub_type'] == 'category' && !isset($post['cfg_data'])) return 'No channel defined.';
Expand Down Expand Up @@ -320,9 +319,10 @@ function update($post) {
if ($handler == 'cfg_destination' && $post[$handler] == 'syslog') {
$post['cfg_data'] = $post['cfg_syslog'];
} elseif ($handler == 'cfg_destination' && $post[$handler] == 'file') {
list($file_path, $file_versions, $file_size, $file_size_spec) = $post['cfg_file_path'];
@list($file_path, $file_versions, $file_size, $file_size_spec) = $post['cfg_file_path'];
$filename = str_replace('"', '', $file_path);
$post['cfg_data'] = '"' . $filename . '" versions ' . $file_versions;
$post['cfg_data'] = '"' . $filename . '"';
if ($file_versions) $post['cfg_data'] .= ' versions ' . $file_versions;
if (!empty($file_size) && $file_size > 0) $post['cfg_data'] .= ' size ' . $file_size . $file_size_spec;
}
if ($handler == 'cfg_destination') {
Expand Down Expand Up @@ -472,9 +472,9 @@ function printForm($data = '', $action = 'add', $type = 'channel') {
$cfg_print_time = buildSelect('print-time', 'print-time', $__FM_CONFIG['logging']['options']['print-time'], $this->getChannel($cfg_id, 'print-time'));
$raw_cfg_file_path = explode(' ', str_replace('"', '', $this->getChannel($cfg_id, 'file')));
$cfg_file_path = $raw_cfg_file_path[0];
$cfg_file_versions = @buildSelect('cfg_file_path[]', 'cfg_file_path[]', $__FM_CONFIG['logging']['options']['file_versions'], $raw_cfg_file_path[2]);
$cfg_file_size = (isset($raw_cfg_file_path[4])) ? substr($raw_cfg_file_path[4], 0, -1) : null;
$cfg_file_size_spec = @buildSelect('cfg_file_path[]', 'cfg_file_path[]', $__FM_CONFIG['logging']['options']['file_sizes'], substr($raw_cfg_file_path[4], -1, 1));
$cfg_file_versions = @buildSelect('cfg_file_path[]', 'cfg_file_path[]', $__FM_CONFIG['logging']['options']['file_versions'], $raw_cfg_file_path[array_search('versions', $raw_cfg_file_path) + 1]);
$cfg_file_size = (isset($raw_cfg_file_path[array_search('size', $raw_cfg_file_path) + 1])) ? substr($raw_cfg_file_path[array_search('size', $raw_cfg_file_path) + 1], 0, -1) : null;
$cfg_file_size_spec = @buildSelect('cfg_file_path[]', 'cfg_file_path[]', $__FM_CONFIG['logging']['options']['file_sizes'], substr($raw_cfg_file_path[array_search('size', $raw_cfg_file_path) + 1], -1, 1));

/** Show/hide divs */
if ($dest == 'file' || !$dest) {
Expand All @@ -500,7 +500,7 @@ function printForm($data = '', $action = 'add', $type = 'channel') {
$cfg_destination
<div id="destination_option" style="display: $fileshow">
<input type="text" name="cfg_file_path[]" value="$cfg_file_path" placeholder="/path/to/file" /><br />
$cfg_file_versions <input type="number" name="cfg_file_path[]" value="$cfg_file_size" style="width: 5em;" onkeydown="return validateNumber(event)" />
versions $cfg_file_versions <input type="number" name="cfg_file_path[]" value="$cfg_file_size" style="width: 5em;" onkeydown="return validateNumber(event)" />
$cfg_file_size_spec
</div>
<div id="syslog_options" style="display: $syslogshow">$cfg_syslog</div></td>
Expand Down
2 changes: 1 addition & 1 deletion server/fm-modules/fmDNS/variables.inc.php
Expand Up @@ -89,7 +89,7 @@
/** Logging Channel Options */
$__FM_CONFIG['logging']['options']['destinations'] = array('file', 'syslog', 'stderr', 'null');
$__FM_CONFIG['logging']['options']['file'] = array('versions', 'size');
$__FM_CONFIG['logging']['options']['file_versions'] = array_merge(array('unlimited'), range(1, 10));
$__FM_CONFIG['logging']['options']['file_versions'] = array_merge(array('', 'unlimited'), range(1, 10));
$__FM_CONFIG['logging']['options']['file_sizes'] = array('K', 'M', 'G');
$__FM_CONFIG['logging']['options']['syslog'] = array('kern', 'user', 'mail', 'daemon', 'auth', 'syslog', 'lpr', 'news', 'uucp', 'cron', 'authpriv',
'ftp', 'local0', 'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'local7');
Expand Down

0 comments on commit 9a09109

Please sign in to comment.