istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/ctrlz/topics/assets/templates/scopes.html (about)

     1  {{ define "content" }}
     2  <p>
     3          Logging for this process is organized in scopes. Each scope has different
     4          output controls which determine how much and what kind of logging is produced
     5          by the scope.
     6  </p>
     7  
     8  <table>
     9      <thead>
    10          <tr>
    11              <th>Scope</th>
    12              <th>Description</th>
    13              <th>Output Level</th>
    14              <th>Stack Trace Level</th>
    15              <th>Log Callers?</th>
    16          </tr>
    17      </thead>
    18  
    19      <tbody>
    20  
    21          {{ range $index, $value := . }}
    22              <tr id="{{$value.Name}}">
    23                  <td>{{$value.Name}}</td>
    24                  <td>{{$value.Description}}</td>
    25                  <td class="text-center">
    26                      <div class="dropdown">
    27                          <button id="outputLevel" class="btn btn-istio dropdown-toggle" type="button" data-toggle="dropdown">
    28                              {{$value.OutputLevel}}
    29                          </button>
    30                          <div class="dropdown-menu">
    31                              <a class="dropdown-item" onclick="selectOutputLevel(this, 'none')">none</a>
    32                              <a class="dropdown-item" onclick="selectOutputLevel(this, 'error')">error</a>
    33                              <a class="dropdown-item" onclick="selectOutputLevel(this, 'warn')">warn</a>
    34                              <a class="dropdown-item" onclick="selectOutputLevel(this, 'info')">info</a>
    35                              <a class="dropdown-item" onclick="selectOutputLevel(this, 'debug')">debug</a>
    36                          </div>
    37                      </div>
    38                  </td>
    39  
    40                  <td class="text-center">
    41                      <div class="dropdown">
    42                          <button id="stackTraceLevel" class="btn btn-istio dropdown-toggle" type="button" data-toggle="dropdown">
    43                          {{$value.StackTraceLevel}}
    44                          </button>
    45                          <div class="dropdown-menu">
    46                              <a class="dropdown-item" onclick="selectStackTraceLevel(this, 'none')">none</a>
    47                              <a class="dropdown-item" onclick="selectStackTraceLevel(this, 'error')">error</a>
    48                              <a class="dropdown-item" onclick="selectStackTraceLevel(this, 'warn')">warn</a>
    49                              <a class="dropdown-item" onclick="selectStackTraceLevel(this, 'info')">info</a>
    50                              <a class="dropdown-item" onclick="selectStackTraceLevel(this, 'debug')">debug</a>
    51                          </div>
    52                      </div>
    53                  </td>
    54  
    55                  <td class="text-center">
    56                      {{ if $value.LogCallers}}
    57                          <input id="logCallers" onclick="toggleLogCallers(this)" type="checkbox" checked="checked">
    58                      {{ else }}
    59                          <input id="logCallers" onclick="toggleLogCallers(this)" type="checkbox">
    60                      {{ end }}
    61                  </td>
    62              </tr>
    63          {{ end }}
    64  
    65      </tbody>
    66  </table>
    67  
    68  {{ template "last-refresh" .}}
    69  
    70  <script>
    71      "use strict";
    72  
    73      function refreshScopes() {
    74          let url = window.location.protocol + "//" + window.location.host + "/scopej/";
    75  
    76          let ajax = new XMLHttpRequest();
    77          ajax.onload = onload;
    78          ajax.onerror = onerror;
    79          ajax.open("GET", url, true);
    80          ajax.send();
    81  
    82          function onload() {
    83              if (this.status === 200) { // request succeeded
    84                  let si = JSON.parse(this.responseText);
    85                  for (let i = 0; i < si.length; i++) {
    86                      let info = si[i];
    87  
    88                      let tr = document.getElementById(info.name);
    89                      tr.querySelector("#outputLevel").innerText = info.output_level;
    90                      tr.querySelector("#stackTraceLevel").innerText = info.stack_trace_level;
    91                      tr.querySelector("#logCallers").checked = info.log_callers;
    92                  }
    93  
    94                  updateRefreshTime();
    95              }
    96          }
    97  
    98          function onerror(e) {
    99              console.error(e);
   100          }
   101      }
   102  
   103      function selectOutputLevel(element, level) {
   104          let scope = element.parentElement.parentElement.parentElement.parentElement.id;
   105  
   106          let url = window.location.protocol + "//" + window.location.host + "/scopej/" + scope;
   107          let ajax = new XMLHttpRequest();
   108          ajax.onload = onload;
   109          ajax.onerror = onerror;
   110          ajax.open("GET", url, true);
   111          ajax.send();
   112  
   113          function onload() {
   114              if (this.status === 200) { // request succeeded
   115                  let si = JSON.parse(this.responseText);
   116                  si.output_level = level;
   117  
   118                  let url = window.location.protocol + "//" + window.location.host + "/scopej/" + scope;
   119                  let ajax = new XMLHttpRequest();
   120                  ajax.onload = onload2;
   121                  ajax.onerror = onerror;
   122                  ajax.open("PUT", url, true);
   123                  ajax.send(JSON.stringify(si));
   124              }
   125  
   126              function onload2() {
   127                  refreshScopes();
   128              }
   129          }
   130  
   131          function onerror(e) {
   132              console.error(e);
   133          }
   134      }
   135  
   136      function selectStackTraceLevel(element, level) {
   137          let scope = element.parentElement.parentElement.parentElement.parentElement.id;
   138  
   139          let url = window.location.protocol + "//" + window.location.host + "/scopej/" + scope;
   140          let ajax = new XMLHttpRequest();
   141          ajax.onload = onload;
   142          ajax.onerror = onerror;
   143          ajax.open("GET", url, true);
   144          ajax.send();
   145  
   146          function onload() {
   147              if (this.status === 200) { // request succeeded
   148                  let si = JSON.parse(this.responseText);
   149                  si.stack_trace_level = level;
   150  
   151                  let url = window.location.protocol + "//" + window.location.host + "/scopej/" + scope;
   152                  let ajax = new XMLHttpRequest();
   153                  ajax.onload = onload2;
   154                  ajax.onerror = onerror;
   155                  ajax.open("PUT", url, true);
   156                  ajax.send(JSON.stringify(si));
   157              }
   158  
   159              function onload2() {
   160                  refreshScopes();
   161              }
   162          }
   163  
   164          function onerror(e) {
   165              console.error(e);
   166          }
   167      }
   168  
   169      function toggleLogCallers(checkbox) {
   170          let scope = checkbox.parentElement.parentElement.id;
   171          let logCallers = checkbox.checked;
   172  
   173          let url = window.location.protocol + "//" + window.location.host + "/scopej/" + scope;
   174          let ajax = new XMLHttpRequest();
   175          ajax.onload = onload;
   176          ajax.onerror = onerror;
   177          ajax.open("GET", url, true);
   178          ajax.send();
   179  
   180          function onload() {
   181              if (this.status === 200) { // request succeeded
   182                  let si = JSON.parse(this.responseText);
   183                  si.log_callers = logCallers;
   184  
   185                  let url = window.location.protocol + "//" + window.location.host + "/scopej/" + scope;
   186                  let ajax = new XMLHttpRequest();
   187                  ajax.onload = onload2;
   188                  ajax.onerror = onerror;
   189                  ajax.open("PUT", url, true);
   190                  ajax.send(JSON.stringify(si));
   191              }
   192  
   193              function onload2() {
   194              }
   195          }
   196  
   197          function onerror(e) {
   198              console.error(e);
   199          }
   200      }
   201  
   202      refreshScopes();
   203      window.setInterval(refreshScopes, 1000);
   204  </script>
   205  
   206  {{ end }}