Main.js 26 KB

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