Main.js 26 KB

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