From 09ad0d01d363e9ece1e132cb1331a5ab880748de Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Aug 27 2018 19:48:23 +0000 Subject: Ticket 49877 - Add log level functionality to UI Description: Add logic to get and save the access & errors log levels in the UI tables https://pagure.io/389-ds-base/issue/49877 Reviewed by: ? --- diff --git a/src/cockpit/389-console/js/servers.js b/src/cockpit/389-console/js/servers.js index a2bd9e0..0323d5c 100644 --- a/src/cockpit/389-console/js/servers.js +++ b/src/cockpit/389-console/js/servers.js @@ -76,6 +76,11 @@ var create_inf_template = var sasl_table; var pwp_table; +// log levels +var accesslog_levels = [4, 256, 512] +var errorlog_levels = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 2048, + 4096, 8192, 16384, 32768, 65536, 262144, 1048576]; + function load_server_config() { var mark = document.getElementById("server-config-title"); mark.innerHTML = "Configuration for server: " + server_id + ""; @@ -154,6 +159,10 @@ function get_and_set_config () { var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','config', 'get']; cockpit.spawn(cmd, { superuser: true, "err": "message", "environ": [ENV]}).done(function(data) { var obj = JSON.parse(data); + // Reset tables before populating them + $(".ds-accesslog-table").prop('checked', false); + $(".ds-errorlog-table").prop('checked', false); + for (var attr in obj['attrs']) { var val = obj['attrs'][attr][0]; attr = attr.toLowerCase(); @@ -169,6 +178,23 @@ function get_and_set_config () { } config_values[attr] = val; } + + // Do the log level tables + if (attr == "nsslapd-accesslog-level") { + var level_val = parseInt(val); + for ( var level in accesslog_levels ) { + if (level_val & accesslog_levels[level]) { + $("#accesslog-" + accesslog_levels[level].toString()).prop('checked', true); + } + } + } else if (attr == "nsslapd-errorlog-level") { + var level_val = parseInt(val); + for ( var level in errorlog_levels ) { + if (level_val & errorlog_levels[level]) { + $("#errorlog-" + errorlog_levels[level].toString()).prop('checked', true); + } + } + } } check_inst_alive(); }).fail(function(data) { @@ -320,6 +346,32 @@ function save_config() { } } + // Save access log levels + var access_log_level = 0; + $(".ds-accesslog-table").each(function() { + var val = this.id; + if (this.checked){ + val = parseInt(val.replace("accesslog-", "")); + access_log_level += val; + } + }); + mod['attr'] = "nsslapd-accesslog-level"; + mod['val'] = access_log_level; + mod_list.push(mod); + + // Save error log levels + var error_log_level = 0; + $(".ds-errorlog-table").each(function() { + var val = this.id; + if (this.checked) { + val = parseInt(val.replace("errorlog-", "")); + error_log_level += val; + } + }); + mod['attr'] = "nsslapd-errorlog-level"; + mod['val'] = error_log_level; + mod_list.push(mod); + // Build dsconf commands to apply all the mods if (mod_list.length) { apply_mods(mod_list); diff --git a/src/cockpit/389-console/servers.html b/src/cockpit/389-console/servers.html index 67fc3d0..94895a6 100644 --- a/src/cockpit/389-console/servers.html +++ b/src/cockpit/389-console/servers.html @@ -554,7 +554,7 @@
- +
@@ -563,11 +563,15 @@ - + + + + + - + @@ -767,63 +771,63 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +
Default Logging
Internal Operations
Entry Access and Referrals
Trace Function Calls
Packet Handling
Heavy Trace Output
Connection Management
Packets Sent/Received
Search Filter Processing
Config File Processing
Access Control List Processing
Log Entry Parsing
Housekeeping
Replication
Entry Cache
Plug-ins
Access Control Summary
Nunc-Stans Connection Logging