Main.js 26 KB

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