You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.6 KiB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
  6. <script src="../js/zcmd.js"></script>
  7. <meta name="viewport" content="width=device-width,initial-scale=1">
  8. <title>日志配置</title>
  9. <style>
  10. </style>
  11. <script>
  12. </script>
  13. </head>
  14. <body>
  15. <!--
  16. 选择框:main,service
  17. 选择框:等级(debug,info,warning,error)
  18. 设置日志等级:按钮
  19. -->
  20. <div>
  21. <select id="logger">
  22. <option value="main">main</option>
  23. <option value="service">service</option>
  24. </select>
  25. <select id="level">
  26. <option value=0>trace</option>
  27. <option value=1>debug</option>
  28. <option value=2>info</option>
  29. <option value=3>warning</option>
  30. <option value=4>error</option>
  31. <option value=5>critical</option>
  32. </select>
  33. <button id="set">设置日志等级</button>
  34. </div>
  35. <script>
  36. $(function () {
  37. var zcmd = new ZCommand();
  38. zcmd.set_onSendraw(function (data) {
  39. console.log("zcmd send:" + JSON.stringify(data, null, 0));
  40. });
  41. zcmd.set_onReceipt(function (tx, rx) {
  42. console.log("zcmd receipt:" + JSON.stringify(rx, null, 0));
  43. });
  44. zcmd.set_onConnected(function () {
  45. console.log("zcmd connected");
  46. //请求日志名称
  47. zcmd.send_message({
  48. "command": "loggerGetAllLoggers",
  49. "need_receipt": true,
  50. }, 4000).then((data) => {
  51. console.log(data);
  52. var html = "";
  53. for (var i = 0; i < data.loggers.length; i++) {
  54. html += "<option value='" + data.loggers[i] + "'>" + data.loggers[i] + "</option>";
  55. }
  56. $("#logger").html(html);
  57. });
  58. });
  59. $("#set").click(function () {
  60. zcmd.send_message({
  61. "command": "loggerSetLevel",
  62. "need_receipt": true,
  63. "loggerLevel": Number($("#level").val()),
  64. "loggerName": $("#logger").val(),
  65. }, 4000).then((data) => {
  66. if (data.success) {
  67. alert("设置成功");
  68. } else {
  69. alert("设置失败")
  70. }
  71. });
  72. });
  73. ZWSURL = "ws://127.0.0.1:19000";
  74. zcmd.start_auto_connect(ZWSURL);
  75. });
  76. </script>
  77. </body>
  78. </html>