Main.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. MWF.xApplication.LogViewer.Main = new Class({
  2. Extends: MWF.xApplication.Common.Main,
  3. Implements: [Options, Events],
  4. options: {
  5. "style": "default",
  6. "name": "LogViewer",
  7. "icon": "icon.png",
  8. "width": "800",
  9. "height": "600",
  10. "title": MWF.xApplication.LogViewer.LP.title
  11. },
  12. onQueryLoad: function(){
  13. this.lp = MWF.xApplication.LogViewer.LP;
  14. this.tagId = o2.uuid();
  15. },
  16. loadApplication: function(callback){
  17. if (!this.options.isRefresh){
  18. this.maxSize(function(){
  19. this.doLog();
  20. }.bind(this));
  21. }else{
  22. this.doLog();
  23. }
  24. if (callback) callback();
  25. },
  26. doLog: function(){
  27. this.status = "systemLog";
  28. this.actions = MWF.Actions.get("x_program_center");
  29. this.node = new Element("div", {"styles": this.css.contentNode}).inject(this.content);
  30. this.toolbarNode = new Element("div", {"styles": this.css.toolbarNode}).inject(this.node);
  31. this.screenNode = new Element("div", {"styles": this.css.screenNode}).inject(this.node);
  32. this.bottomNode = new Element("div", {"styles": this.css.bottomNode}).inject(this.node);
  33. this.loadToolbar();
  34. this.loadScreen();
  35. this.loadBottom();
  36. this.initLog();
  37. this.loadLog();
  38. },
  39. initLog: function(){
  40. this.screenInforAreaNode.empty();
  41. this.date = this.dateSelect.options[this.dateSelect.selectedIndex];
  42. this.method = "listPromptErrorLog";
  43. this.count = 20;
  44. this.currentId = "(0)";
  45. //定时器
  46. },
  47. loadBottom: function(){
  48. this.nodeSelect = new Element("select", {"styles": this.css.toolbarNodeSelect}).inject(this.bottomNode);
  49. o2.Actions.load("x_program_center").CommandAction.getNodeInfoList(
  50. function( json ){
  51. var nodeList = json.data.nodeList;
  52. nodeList.each(function (node) {
  53. new Element("option", {
  54. "value": node.node.nodeAgentPort,
  55. "text": node.nodeAddress
  56. }).inject(this.nodeSelect);
  57. }.bind(this));
  58. }.bind(this),null, false
  59. );
  60. this.commandNode = new Element("input",{"styles":this.css.commandNode}).inject(this.bottomNode);
  61. this.commandBtnNode = new Element("button",{"text":"submit","styles":this.css.commandBtnNode}).inject(this.bottomNode);
  62. this.commandNode.addEvent('keyup', function(e) {
  63. if(e.key==="enter"){
  64. this.executeCommand();
  65. }
  66. }.bind(this));
  67. this.commandBtnNode.addEvent("click",function () {
  68. this.executeCommand();
  69. }.bind(this));
  70. },
  71. executeCommand : function(){
  72. if(this.commandNode.get("value")!==""){
  73. var data = {};
  74. data["ctl"] = this.commandNode.get("value");
  75. data["nodeName"] = this.nodeSelect.getElement("option:selected").get("text");
  76. data["nodePort"] = this.nodeSelect.getElement("option:selected").get("value");
  77. o2.Actions.load("x_program_center").CommandAction.executeCommand(data, function( json ){
  78. this.commandNode.set("value","");
  79. }.bind(this),null, false);
  80. }
  81. },
  82. loadToolbar: function(){
  83. this.systemLogButton = this.createTopButton("SystemLog", "systemLog.png", "systemLog");
  84. this.promptErrorButton = this.createTopButton("PromptError", "prompt.png", "prompt");
  85. this.unexpectedErrorButton = this.createTopButton("UnexpectedError", "unexpected.png", "unexpected");
  86. this.warnErrorButton = this.createTopButton("Warn", "warn.png", "warn");
  87. this.dateSelect = new Element("select", {"styles": this.css.toolbarDateSelect}).inject(this.toolbarNode);
  88. new Element("option", {
  89. "value": "all",
  90. "selected": true,
  91. "text": this.lp.current
  92. }).inject(this.dateSelect);
  93. var d = new Date();
  94. var t = d.format("%Y-%m-%d");
  95. new Element("option", { "value": t, "text": t }).inject(this.dateSelect);
  96. for (var i=0; i<=7; i++){
  97. d = d.decrement("day", 1);
  98. t = d.format("%Y-%m-%d");
  99. new Element("option", { "value": t, "text": t }).inject(this.dateSelect);
  100. }
  101. this.dateSelect.addEvent("change", function(){
  102. this.initLog();
  103. this.loadLog();
  104. }.bind(this));
  105. // this.promptErrorButton.addEvent("click", function(){
  106. // this.showTypeLog("prompt");
  107. // }.bind(this));
  108. // this.unexpectedErrorButton.addEvent("click", function(){
  109. // this.showTypeLog("unexpected");
  110. // }.bind(this));
  111. // this.warnErrorButton.addEvent("click", function(){
  112. // this.showTypeLog("warn");
  113. // }.bind(this));
  114. this.clearBtn = new Element("button",{"text":"clear","style":"margin:10px;float:right"}).inject(this.toolbarNode);
  115. this.clearBtn.addEvent("click",function () {
  116. this.screenInforAreaNode.empty();
  117. this.tagId = o2.uuid();
  118. }.bind(this));
  119. this.stopBtn = new Element("button",{"text":"stop","style":"margin:10px;float:right"}).inject(this.toolbarNode);
  120. this.startBtn = new Element("button",{"text":"start","style":"margin:10px;display:none;;float:right"}).inject(this.toolbarNode);
  121. this.stopBtn.addEvent("click",function () {
  122. this.startBtn.show();
  123. this.stopBtn.hide();
  124. if(this.method==="listSystemLog"){
  125. $clear(this.timeDo);
  126. this.timeDo = null;
  127. }else {
  128. this.initLog();
  129. this.loadLog();
  130. }
  131. }.bind(this));
  132. this.startBtn.addEvent("click",function () {
  133. this.startBtn.hide();
  134. this.stopBtn.show();
  135. this.initLog();
  136. this.loadLog();
  137. }.bind(this));
  138. },
  139. showTypeLog: function(status){
  140. $clear(this.timeDo);
  141. this.timeDo = null;
  142. if (this.status!==status){
  143. switch (this.status){
  144. case "prompt":
  145. this.promptErrorButton.setStyles(this.css.toolbarButton);
  146. break;
  147. case "unexpected":
  148. this.unexpectedErrorButton.setStyles(this.css.toolbarButton);
  149. break;
  150. case "warn":
  151. this.warnErrorButton.setStyles(this.css.toolbarButton);
  152. break;
  153. case "systemLog":
  154. this.systemLogButton.setStyles(this.css.toolbarButton);
  155. break;
  156. }
  157. switch (status){
  158. case "prompt":
  159. this.promptErrorButton.setStyles(this.css.toolbarButton_down);
  160. this.status="prompt";
  161. break;
  162. case "unexpected":
  163. this.unexpectedErrorButton.setStyles(this.css.toolbarButton_down);
  164. this.status="unexpected";
  165. break;
  166. case "warn":
  167. this.warnErrorButton.setStyles(this.css.toolbarButton_down);
  168. this.status="warn";
  169. break;
  170. case "systemLog":
  171. this.systemLogButton.setStyles(this.css.toolbarButton_down);
  172. this.status="systemLog";
  173. break;
  174. default:
  175. this.promptErrorButton.setStyles(this.css.toolbarButton_down);
  176. this.status="prompt";
  177. }
  178. this.initLog();
  179. this.loadLog();
  180. }
  181. },
  182. createTopButton: function(text, img, status){
  183. var node = new Element("div", {"styles": this.css.toolbarButton}).inject(this.toolbarNode);
  184. var iconNode = new Element("div", {"styles": this.css.toolbarIconButton}).inject(node);
  185. var textNode = new Element("div", {"styles": this.css.toolbarTextButton, "text": text}).inject(node);
  186. iconNode.setStyle("background-image", "url("+"/x_component_LogViewer/$Main/default/"+img+")");
  187. if (status==this.status) node.setStyles(this.css.toolbarButton_down);
  188. var _self = this;
  189. node.addEvents({
  190. "mouseover": function(){if (_self.status != status) this.setStyles(_self.css.toolbarButton_over);},
  191. "mousedown": function(){if (_self.status != status) this.setStyles(_self.css.toolbarButton_down);},
  192. "mouseup": function(){if (_self.status != status) this.setStyles(_self.css.toolbarButton_over);},
  193. "mouseout": function(){if (_self.status != status) this.setStyles(_self.css.toolbarButton);},
  194. "click": function(){_self.showTypeLog(status);}.bind(this)
  195. });
  196. return node;
  197. },
  198. loadLog: function(){
  199. this.date = this.dateSelect.options[this.dateSelect.selectedIndex].value;
  200. switch (this.status){
  201. case "prompt":
  202. this.method = (this.date==="all") ? "listPromptErrorLog" : "listPromptErrorLogWithDate";
  203. break;
  204. case "unexpected":
  205. this.method = (this.date==="all") ? "listUnexpectedErrorLog" : "listUnexpectedErrorLogWithDate";
  206. break;
  207. case "warn":
  208. this.method = (this.date==="all") ? "listWarnLog" : "listWarnLogWithDate";
  209. break;
  210. case "systemLog":
  211. this.method = "listSystemLog";
  212. break;
  213. default:
  214. //this.method = (this.date==="all") ? "listPromptErrorLog" : "listPromptErrorLogWithDate";
  215. this.method = "listSystemLog";
  216. }
  217. if(this.method==="listSystemLog"){
  218. this.actions[this.method](this.tagId, function(json){
  219. this.showSystemLog(json.data);
  220. }.bind(this));
  221. //添加定时器
  222. this.timeDo = this.tiemShowSystemLog.periodical(1000,this);
  223. }else{
  224. if (this.date==="all"){
  225. this.actions[this.method](this.currentId, this.count, function(json){
  226. this.showLog(json.data);
  227. }.bind(this));
  228. }else{
  229. var d = new Date().parse(this.date).format("%Y-%m-%d");
  230. this.actions[this.method](this.currentId, this.count, d, function(json){
  231. this.showLog(json.data);
  232. }.bind(this));
  233. }
  234. }
  235. },
  236. showSystemLog : function(data){
  237. this.logFinish = true;
  238. data.each(function (log) {
  239. var node = new Element("div", {"styles": this.css.logItemNode}).inject(this.screenInforAreaNode);
  240. if(log.logLevel){
  241. var lineLog = log.lineLog;
  242. var logTime = log.logTime.split("#")[0];
  243. lineLog = lineLog.replace(logTime,"");
  244. lineLog = lineLog.replace(log.logLevel,"");
  245. var typeNode = new Element("div",{
  246. "html" : log.logLevel,
  247. "title" : log.node,
  248. "style" : "float:left;margin:0 10px;width:50px;font-weight:500;"
  249. }).inject(node);
  250. var color = "#FF0000";
  251. switch (log.logLevel) {
  252. case "INFO" :
  253. color = "#5a86ff";
  254. break;
  255. case "PRINT" :
  256. color = "#ffd192";
  257. break;
  258. case "DEBUG" :
  259. color = "#d7ff3d";
  260. break;
  261. default :
  262. }
  263. typeNode.setStyle("color",color);
  264. var timeNode = new Element("div",{
  265. "html" : logTime,
  266. "style" : "float:left;margin:0 10px;width:180px;color:#6BC5FC"
  267. }).inject(node);
  268. }
  269. var contentNode = new Element("div",{
  270. "text" : log.lineLog,
  271. "style" : "margin-left:270px"
  272. }).inject(node);
  273. }.bind(this));
  274. },
  275. tiemShowSystemLog : function(){
  276. this.actions[this.method](this.tagId, function(json){
  277. this.showSystemLog(json.data);
  278. this.screenInforAreaNode.scrollTop = this.screenInforAreaNode.scrollHeight;
  279. }.bind(this));
  280. },
  281. showLog: function(data){
  282. if (data.length){
  283. var last = data[data.length-1];
  284. this.currentId = last.id;
  285. data.each(function(log){
  286. new MWF.xApplication.LogViewer.Log(log, this);
  287. }.bind(this));
  288. // switch (this.status){
  289. // case "prompt":
  290. // this.showPromptLog(data);
  291. // break;
  292. // case "unexpected":
  293. // this.showUnexpectedLog(data);
  294. // break;
  295. // case "warn":
  296. // this.showWarnLog(data);
  297. // break;
  298. // default:
  299. // this.showPromptLog(data);
  300. // }
  301. }else{
  302. this.logFinish = true;
  303. }
  304. this.checkLoadNext();
  305. },
  306. checkLoadNext: function(){
  307. if (!this.logFinish){
  308. var s = this.screenInforAreaNode.getScroll();
  309. var ssize = this.screenInforAreaNode.getScrollSize();
  310. var size = this.screenInforAreaNode.getSize();
  311. if (ssize.y-s.y-size.y<200){
  312. this.loadLog();
  313. }
  314. }
  315. },
  316. // showPromptLog: function(data){
  317. // data.each(function(log){
  318. // new MWF.xApplication.LogViewer.Log(log, this);
  319. // }.bind(this));
  320. // },
  321. begin: function(){
  322. this.beginButton.setStyle("background-image", "url("+"/x_component_Console/$Main/default/play_gray.png)");
  323. this.stopButton.setStyle("background-image", "url("+"/x_component_Console/$Main/default/stop.png)");
  324. this.status = "begin";
  325. },
  326. stop: function(){
  327. this.beginButton.setStyle("background-image", "url("+"/x_component_Console/$Main/default/play.png)");
  328. this.stopButton.setStyle("background-image", "url("+"/x_component_Console/$Main/default/stop_gray.png)");
  329. this.status = "stop";
  330. },
  331. loadScreen: function(){
  332. this.screenInforAreaNode = new Element("div", {"styles": this.css.screenInforAreaNode}).inject(this.screenNode);
  333. this.screenInforAreaNode.addEvent("scroll", function(){
  334. this.checkLoadNext();
  335. }.bind(this));
  336. //this.screenInforAreaNode = new Element("div", {"styles": this.css.screenInforAreaNode}).inject(this.screenScrollNode);
  337. // MWF.require("MWF.widget.ScrollBar", function(){
  338. // new MWF.widget.ScrollBar(this.screenScrollNode, {
  339. // "style":"xApp_console", "where": "before", "indent": false, "distance": 50, "friction": 6, "axis": {"x": false, "y": true},
  340. // "onScroll": function(y, x){
  341. // // var scrollSize = _self.listScrollAreaNode.getScrollSize();
  342. // // var clientSize = _self.listScrollAreaNode.getSize();
  343. // // var scrollHeight = scrollSize.y-clientSize.y;
  344. // // if (y+200>scrollHeight) {
  345. // // if (!_self.isElementLoaded) _self.listItemNext();
  346. // // }
  347. // }
  348. // });
  349. // }.bind(this));
  350. this.setScreenHeight();
  351. this.addEvent("resize", this.setScreenHeight.bind(this));
  352. },
  353. setScreenHeight: function(){
  354. var size = this.node.getSize();
  355. var toolbarSize = this.toolbarNode.getSize();
  356. var bottomSize = this.bottomNode.getSize();
  357. var y = size.y-toolbarSize.y-bottomSize.y;
  358. this.screenNode.setStyle("height", ""+y+"px");
  359. }
  360. });
  361. MWF.xApplication.LogViewer.Log = new Class({
  362. initialize: function(log, app){
  363. this.log = log;
  364. this.app = app;
  365. this.css = this.app.css;
  366. this.lp = this.app.lp;
  367. this.load();
  368. },
  369. load: function(){
  370. this.node = new Element("div", {"styles": this.css.logItemNode}).inject(this.app.screenInforAreaNode);
  371. var m = this.log.message.substr(0, this.log.message.indexOf("\n"));
  372. var message = m + ((this.log.person) ? "&nbsp;("+this.log.person+")": "");
  373. var html = "<pre><span class='MWFLogCheckbox' style='cursor: pointer;float: left; height: 20px; width: 30px; background: url(/x_component_LogViewer/$Main/default/check.png) no-repeat center center'></span>" +
  374. "<span style='float: left;font-size: 14px; font-weight: bold; width: 160px; text-align: right'>"+this.log.occurTime+"</span>" +
  375. "<span style='float:left'>\t</span>" +
  376. "<span style='font-size: 14px; font-weight: bold;'>"+o2.common.encodeHtml(message)+"</span><br/>";
  377. if (this.log.exceptionClass){
  378. html += "<span style='float: left; width: 190px; text-align: right; color: #6BC5FC;'>ExceptionClass: </span>" +
  379. "<span style='float:left'>\t</span>" +
  380. "<span>"+o2.common.encodeHtml(this.log.exceptionClass)+"</span><br/>";
  381. }
  382. if (this.log.loggerName){
  383. html += "<span style='float: left; width: 190px; text-align: right; color: #6BC5FC;'>LoggerName: </span>" +
  384. "<span style='float:left'>\t</span>" +
  385. "<span>"+o2.common.encodeHtml(this.log.loggerName)+"</span><br/>";
  386. }
  387. if (this.log.stackTrace){
  388. var traces = this.log.stackTrace.split(/[\r\n\t]/g);
  389. html += "<span class='MWFLogStackTrace'><span style='float: left; width: 190px; text-align: right; color: #6BC5FC;'>StackTrace: </span>" +
  390. "<span style='float:left'>\t</span>";
  391. if (traces.length>1) {
  392. html += "<span class='MWFLogStackTraceAction' style='float: left; cursor: pointer; height: 20px; width: 16px; background: url(/x_component_LogViewer/$Main/default/right.png) no-repeat left center'></span>";
  393. }
  394. html += "<span>"+o2.common.encodeHtml(traces[0])+"</span></span><br/>";
  395. // traces.each(function(trace, i){
  396. // if (i!==0){
  397. // html += "<span style='float: left; width: 190px; text-align: right; color: #6BC5FC;'>&nbsp;</span>" +
  398. // "<span>&nbsp;&nbsp;</span>" +
  399. // "<span>\t"+trace+"</span><br/>";
  400. // }
  401. // }.bind(this));
  402. }
  403. if (this.log.requestUrl){
  404. var request = ((this.log.requestMethod) ? this.log.requestMethod+"&nbsp;": "")+
  405. this.log.requestUrl+
  406. ((this.log.requestRemoteAddr) ? "&nbsp; From &nbsp;"+this.log.requestRemoteAddr : "");
  407. html += "<span class='MWFLogRequest'><span style='float: left; width: 190px; text-align: right; color: #6BC5FC;'>RequestInfor: </span>" +
  408. "<span style='float:left'>\t</span>";
  409. html += "<span class='MWFLogRequestAction' style='float: left;cursor: pointer; height: 20px; width: 16px; background: url(/x_component_LogViewer/$Main/default/right.png) no-repeat left center'></span>";
  410. html += "<span>"+o2.common.encodeHtml(request)+"</span></span><br/>";
  411. }
  412. html += "</pre>";
  413. this.node.set("html", html);
  414. this.checkbox = this.node.getElement(".MWFLogCheckbox");
  415. this.traceNode = this.node.getElement(".MWFLogStackTrace");
  416. this.requestNode = this.node.getElement(".MWFLogRequest");
  417. this.traceActionNode = this.node.getElement(".MWFLogStackTraceAction");
  418. this.requestActionNode = this.node.getElement(".MWFLogRequestAction");
  419. this.setEvent();
  420. },
  421. setEvent: function(){
  422. this.node.addEvents({
  423. "mouseover": function(){ this.node.setStyles(this.css.logItemNode_over); }.bind(this),
  424. "mouseout": function(){ this.node.setStyles(this.css.logItemNode); }.bind(this)
  425. });
  426. if (this.checkbox){
  427. this.checkbox.addEvent("click", function(e){
  428. this.checkSelected();
  429. e.stopPropagation();
  430. }.bind(this))
  431. }
  432. if (this.traceActionNode){
  433. this.traceActionNode.addEvent("click", function(e){
  434. this.expandOrCollapseTrace();
  435. e.stopPropagation();
  436. }.bind(this))
  437. }
  438. if (this.requestActionNode){
  439. this.requestActionNode.addEvent("click", function(e){
  440. this.expandOrCollapseRequest();
  441. e.stopPropagation();
  442. }.bind(this))
  443. }
  444. },
  445. checkSelected: function(){
  446. var range = document.createRange();
  447. range.selectNode(this.node);
  448. var s = window.getSelection();
  449. s.selectAllChildren(this.node);
  450. },
  451. expandOrCollapseTrace: function(){
  452. if (this.log.stackTrace){
  453. if (!this.isTraceExpanded){
  454. this.expandedTrace();
  455. }else{
  456. this.collapseTrace();
  457. }
  458. }
  459. },
  460. expandedTrace: function(){
  461. if (!this.traceAllNode) this.createTraceAllNode();
  462. this.traceAllNode.setStyle("display", "inline");
  463. this.traceActionNode.setStyle("background-image", "url(/x_component_LogViewer/$Main/default/down.png)");
  464. this.isTraceExpanded = true;
  465. },
  466. collapseTrace: function(){
  467. if (this.traceAllNode){
  468. this.traceAllNode.destroy();
  469. this.traceAllNode = null;
  470. }
  471. this.traceActionNode.setStyle("background-image", "url(/x_component_LogViewer/$Main/default/right.png)");
  472. this.isTraceExpanded = false;
  473. },
  474. createTraceAllNode: function(){
  475. var brNode = this.traceNode.getNext();
  476. this.traceAllNode = new Element("span").inject(brNode, "after");
  477. var traces = this.log.stackTrace.split(/[\r\n\t]/g);
  478. var html = "";
  479. traces.each(function(t, i){
  480. if (i!==0){
  481. html += "<span style='float: left; width: 190px;'>\t</span>" +
  482. "<span>\t</span>" +
  483. "<span>\t"+t+"</span><br/>";
  484. }
  485. }.bind(this));
  486. this.traceAllNode.set("html", html);
  487. },
  488. expandOrCollapseRequest: function(){
  489. if (this.log.requestUrl){
  490. if (!this.isRequestExpanded){
  491. this.expandedRequest();
  492. }else{
  493. this.collapseRequest();
  494. }
  495. }
  496. },
  497. expandedRequest: function(){
  498. if (!this.requestAllNode) this.createRequestAllNode();
  499. this.requestAllNode.setStyle("display", "inline");
  500. this.requestActionNode.setStyle("background-image", "url(/x_component_LogViewer/$Main/default/down.png)");
  501. this.isRequestExpanded = true;
  502. },
  503. collapseRequest: function(){
  504. if (this.requestAllNode){
  505. this.requestAllNode.destroy();
  506. this.requestAllNode = null;
  507. }
  508. this.requestActionNode.setStyle("background-image", "url(/x_component_LogViewer/$Main/default/right.png)");
  509. this.isRequestExpanded = false;
  510. },
  511. createRequestAllNode: function(){
  512. var brNode = this.requestNode.getNext();
  513. this.requestAllNode = new Element("span").inject(brNode, "after");
  514. var html = "";
  515. html += "<span style='float: left; width: 190px;'>\t</span>" +
  516. "<span style='float: left;'>\t</span>" +
  517. "<span style='color: #6BC5FC; width: 108px;'>requestRemoteAddr: </span><span>"+(this.log.requestRemoteAddr || "&nbsp;")+"</span>&nbsp;&nbsp;" +
  518. "<span style='color: #6BC5FC; width: 108px;'>requestRemoteHost: </span><span>"+(this.log.requestRemoteHost || "&nbsp;")+"</span>&nbsp;&nbsp;" +
  519. "<span style='color: #6BC5FC; width: 108px;'>requestBodyLength: </span><span>"+(this.log.requestBodyLength || "&nbsp;")+"</span>" +
  520. "<br/>";
  521. // if (this.log.requestHead) html += "<span style='float: left; width: 190px;'>\t</span>" +
  522. // "<span style='float: left;'>\t</span>" +
  523. // "<span style='float: left; color: #6BC5FC; width: 108px;'>requestHead: </span><span style='word-break:break-all;'>"+this.log.requestHead+"</span><br/>";
  524. var headers = this.log.requestHead.split(/\n/g);
  525. headers.each(function(head, i){
  526. if (i===0){
  527. html += "<span style='float: left; width: 190px;'>\t</span>" +
  528. "<span style='float: left;'>\t</span>" +
  529. "<span style='float: left; color: #6BC5FC; width: 108px;'>requestHead: </span><span>"+head+"</span><br/>";
  530. }else{
  531. html += "<span style='float: left; width: 190px;'>\t</span>" +
  532. "<span style='float: left;'>\t</span>" +
  533. "<span style='float: left; color: #6BC5FC; width: 108px;'>\t</span><span>"+head+"</span><br/>";
  534. }
  535. }.bind(this));
  536. if (this.log.requestBody){
  537. var bodys = this.log.requestBody.split(/\n/g);
  538. bodys.each(function(body, i){
  539. if (i===0){
  540. html += "<span style='float: left; width: 190px;'>\t</span>" +
  541. "<span style='float: left;'>\t</span>" +
  542. "<span style='float: left; color: #6BC5FC; width: 108px;'>requestBody: </span><span>"+body+"</span><br/>";
  543. }else{
  544. html += "<span style='float: left; width: 190px;'>\t</span>" +
  545. "<span style='float: left;'>\t</span>" +
  546. "<span style='float: left; color: #6BC5FC; width: 108px;'>\t</span><span>"+body+"</span><br/>";
  547. }
  548. }.bind(this));
  549. }
  550. // requestHead
  551. // requestRemoteAddr
  552. // requestRemoteHost
  553. // requestBodyLength
  554. // requestBody
  555. this.requestAllNode.set("html", html);
  556. }
  557. });