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.
86 lines
2.6 KiB
86 lines
2.6 KiB
<!doctype html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
|
|
<script src="../js/zcmd.js"></script>
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>日志配置</title>
|
|
<style>
|
|
</style>
|
|
<script>
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
<!--
|
|
|
|
选择框:main,service
|
|
选择框:等级(debug,info,warning,error)
|
|
设置日志等级:按钮
|
|
|
|
-->
|
|
<div>
|
|
<select id="logger">
|
|
<option value="main">main</option>
|
|
<option value="service">service</option>
|
|
</select>
|
|
<select id="level">
|
|
<option value=0>trace</option>
|
|
<option value=1>debug</option>
|
|
<option value=2>info</option>
|
|
<option value=3>warning</option>
|
|
<option value=4>error</option>
|
|
<option value=5>critical</option>
|
|
</select>
|
|
<button id="set">设置日志等级</button>
|
|
</div>
|
|
<script>
|
|
$(function () {
|
|
var zcmd = new ZCommand();
|
|
zcmd.set_onSendraw(function (data) {
|
|
console.log("zcmd send:" + JSON.stringify(data, null, 0));
|
|
});
|
|
zcmd.set_onReceipt(function (tx, rx) {
|
|
console.log("zcmd receipt:" + JSON.stringify(rx, null, 0));
|
|
});
|
|
zcmd.set_onConnected(function () {
|
|
console.log("zcmd connected");
|
|
//请求日志名称
|
|
zcmd.send_message({
|
|
"command": "loggerGetAllLoggers",
|
|
"need_receipt": true,
|
|
}, 4000).then((data) => {
|
|
console.log(data);
|
|
var html = "";
|
|
for (var i = 0; i < data.loggers.length; i++) {
|
|
html += "<option value='" + data.loggers[i] + "'>" + data.loggers[i] + "</option>";
|
|
}
|
|
$("#logger").html(html);
|
|
});
|
|
});
|
|
$("#set").click(function () {
|
|
zcmd.send_message({
|
|
"command": "loggerSetLevel",
|
|
"need_receipt": true,
|
|
"loggerLevel": Number($("#level").val()),
|
|
"loggerName": $("#logger").val(),
|
|
}, 4000).then((data) => {
|
|
if (data.success) {
|
|
alert("设置成功");
|
|
} else {
|
|
alert("设置失败")
|
|
}
|
|
});
|
|
});
|
|
ZWSURL = "ws://127.0.0.1:19000";
|
|
zcmd.start_auto_connect(ZWSURL);
|
|
|
|
});
|
|
</script>
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|