#49925 Ticket 49877 - Add log level functionality to UI
Closed 3 years ago by spichugi. Opened 5 years ago by mreynolds.
mreynolds/389-ds-base ticket49877  into  master

@@ -76,6 +76,11 @@ 

  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: <b>" + server_id + "</b>";
@@ -154,6 +159,10 @@ 

    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 @@ 

          }

          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 @@ 

      }

    }

  

+   // 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);

@@ -554,7 +554,7 @@ 

          <hr class="ds-hr-logs">

  

  

-         <table class="table table-striped table-bordered table-hover ds-loglevel-table" id="errorlog-level-table">

+         <table class="table table-striped table-bordered table-hover ds-loglevel-table" id="accesslog-level-table">

            <thead>

              <tr>

                <th class="ds-table-checkbox"></th>
@@ -563,11 +563,15 @@ 

            </thead>

            <tbody>

              <tr>

-              <td class="ds-table-checkbox" id="4"><input type="checkbox"></td>

+              <td class="ds-table-checkbox"><input class="ds-accesslog-table" id="accesslog-256" type="checkbox"></td>

+              <td>Default Logging</td>

+             </tr>

+             <tr>

+              <td class="ds-table-checkbox"><input class="ds-accesslog-table"  id="accesslog-4"type="checkbox"></td>

               <td>Internal Operations</td>

              </tr>

              <tr>

-              <td class="ds-table-checkbox" id="512"><input type="checkbox"></td>

+              <td class="ds-table-checkbox"><input class="ds-accesslog-table" id="accesslog-512" type="checkbox"></td>

               <td>Entry Access and Referrals</td>

              </tr>

            <tbody>
@@ -767,63 +771,63 @@ 

          </thead>

          <tbody>

            <tr>

-            <td class="ds-table-checkbox" id="1"><input type="checkbox"></td>

+            <td class="ds-table-checkbox"><input class="ds-errorlog-table" id="errorlog-1" type="checkbox"></td>

             <td>Trace Function Calls</td>

            </tr>

            <tr>

-            <td class="ds-table-checkbox" id="2"><input type="checkbox"></td>

+            <td class="ds-table-checkbox"><input class="ds-errorlog-table" id="errorlog-2" type="checkbox"></td>

             <td>Packet Handling</td>

            </tr>

            <tr>

-            <td class="ds-table-checkbox" id="4"><input type="checkbox"></td>

+            <td class="ds-table-checkbox"><input class="ds-errorlog-table" id="errorlog-4" type="checkbox"></td>

             <td>Heavy Trace Output</td>

            </tr>

            <tr>

-            <td class="ds-table-checkbox" id="8"><input type="checkbox"></td>

+            <td class="ds-table-checkbox"><input class="ds-errorlog-table" id="errorlog-8" type="checkbox"></td>

             <td>Connection Management</td>

            </tr>

            <tr>

-            <td class="ds-table-checkbox" id="16"><input type="checkbox"></td>

+            <td class="ds-table-checkbox"><input class="ds-errorlog-table" id="errorlog-16" type="checkbox"></td>

             <td>Packets Sent/Received</td>

            </tr>

            <tr>

-            <td class="ds-table-checkbox" id="32"><input type="checkbox"></td>

+            <td class="ds-table-checkbox"><input class="ds-errorlog-table" id="errorlog-32" type="checkbox"></td>

             <td>Search Filter Processing</td>

            </tr>

            <tr>

-            <td class="ds-table-checkbox" id="64"><input type="checkbox"></td>

+            <td class="ds-table-checkbox"><input class="ds-errorlog-table" id="errorlog-64" type="checkbox"></td>

             <td>Config File Processing</td>

            </tr>

            <tr>

-            <td class="ds-table-checkbox" id="128"><input type="checkbox"></td>

+            <td class="ds-table-checkbox"><input class="ds-errorlog-table" id="errorlog-128" type="checkbox"></td>

             <td>Access Control List Processing</td>

            </tr>

            <tr>

-            <td class="ds-table-checkbox" id="2048"><input type="checkbox"></td>

+            <td class="ds-table-checkbox"><input class="ds-errorlog-table" id="errorlog-2048" type="checkbox"></td>

             <td>Log Entry Parsing</td>

            </tr>

            <tr>

-            <td class="ds-table-checkbox" id="4096"><input type="checkbox"></td>

+            <td class="ds-table-checkbox"><input class="ds-errorlog-table" id="errorlog-4096" type="checkbox"></td>

             <td>Housekeeping</td>

            </tr>

            <tr>

-            <td class="ds-table-checkbox" id="8192"><input type="checkbox"></td>

+            <td class="ds-table-checkbox"><input class="ds-errorlog-table" id="errorlog-8192" type="checkbox"></td>

             <td>Replication</td>

            </tr>

            <tr>

-            <td class="ds-table-checkbox" id="32768"><input type="checkbox"></td>

+            <td class="ds-table-checkbox"><input class="ds-errorlog-table" id="errorlog-32768" type="checkbox"></td>

             <td>Entry Cache</td>

            </tr>

            <tr>

-            <td class="ds-table-checkbox" id="65536"><input type="checkbox"></td>

+            <td class="ds-table-checkbox"><input class="ds-errorlog-table" id="errorlog-65536" type="checkbox"></td>

             <td>Plug-ins</td>

            </tr>

            <tr>

-            <td class="ds-table-checkbox" id="262144"><input type="checkbox"></td>

+            <td class="ds-table-checkbox"><input class="ds-errorlog-table" id="errorlog-262144" type="checkbox"></td>

             <td>Access Control Summary</td>

            </tr>

            <tr>

-            <td class="ds-table-checkbox" id="1048576"><input type="checkbox"></td>

+            <td class="ds-table-checkbox"><input class="ds-errorlog-table" id="errorlog-1048576" type="checkbox"></td>

             <td>Nunc-Stans Connection Logging</td>

            </tr>

          </tbody>

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: ?

Pull-Request has been merged by mreynolds

5 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/2984

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago