搜索
首页 电脑/网络 软件 系统软件

JavaScript写Log类如何具体实现 ?

JavaScript写Log类如何具体实现 ?

全部回答

2017-07-28

50 0
    于现在jscript 编写方式比以外负责很多,很多时候都比较难以调试。 为了方便日常程序中的调试,摆弄些下面写Log Class 将需要内容记录下来。 下面就是具体源代码,此Class 只能在 IE浏览器使用。
   1 LogClass。prototype = { 2 3 initialize : function(){ 4 5 try{ 6 7 this。  _fso = ""; //File 操作对象 8 9 this。
  _folderspec = ""; // 类 fileclass 处理路径 10 11 this。_fso = new ActiveXObject("Scripting。FileSystemObject"); // 建立 ActiveXObject 对象 12 13 this。
    _objDate = new Date(); 14 15 this。_DateString = this。_objDate。format("yyMMdd"); 16 17 this。
  _DateString = "c:\\" + this。_DateString + "。  log" ; 18 19 this。_folderspec = this。_DateString; 20 21 22 }catch(e){ 23 24 alert("file Class initialize Error : "+ e。
  number +" "+ e。  description); 25 26 } 27 28 }, 29 TRACE : function(Content){ 30 31 try{ 32 33 this。
  OpenTextFile(8,true); 34 35 _objDate = new Date(); 36 37 _dateString = _objDate。  format("yyyy-MM-dd hh:mm:ss"); 38 39 this。
  _otf。WriteLine(_dateString+"||"+Content); 40 41 this。_otf。close(); 42 43 }catch(e){ 44 45 this。  _otf。
  Close(); 46 47 alert("file Class TRACE Error : "+ e。number +" "+ e。description); 48 49 } 50 51 }, 52 OpenTextFile : function(IOmode,format){ 53 54 try{ 55 56 this。
    _otf = this。_fso。OpenTextFile(this。_folderspec,IOmode,true,format); 57 58 }catch(e){ 59 60 this。
  _otf。Close(); 61 62 alert("file Class OpenTextFile Error : "+ e。  number +" "+ e。description); 63 64 } 65 66 } 67 68 };。
  

类似问题换一批

热点推荐

热度TOP

相关推荐
加载中...

热点搜索 换一换

电脑/网络
系统软件
硬件
电脑装机
程序设计
互联网
操作系统/系统故障
笔记本电脑
反病毒
百度
软件
软件
系统软件
多媒体软件
办公软件
网络软件
图像处理软件
系统软件
系统软件
举报
举报原因(必选):
取消确定举报