当前位置: 首页 > 图文教程 > 开发语言 > Delphi > 用简单的Tracer类来为应用写入跟踪

Delphi
Delphi编程中Http协议应用(一)
Delphi存取图像完整解决方案
简析Delphi中的XML编程
用Delphi实现IP地址的隐藏
Delphi面向对象编程的20条规则
Delphi中的Wrapper设计模式
用Delphi实现软件的在线升级
Delphi7.0实现添加记录的“携带”实现
Delphi编程访问注册表
让Delphi的DBGrid支持鼠标轮
怎样在DELPHI中实现文件切割/组合
Delphi设计可中/英文切换的界面技巧
用Delphi制作以浏览器为界面的应用程序
Delphi 中压缩流和解压流的应用
Delphi控制并行端口位操作
Delphi编写后台监控软件
用Delphi编写VxD设备驱动程序
用Delphi进行OpenGL编程学习心得
DELPHI编程实现3DS的动画播放
用Delphi制作动态菜单

Delphi 中的 用简单的Tracer类来为应用写入跟踪


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-30   浏览: 81 ::
收藏到网摘: n/a

 
=======类的代码=========



{***********************}
{                                             }
{       CodeMachine                 }
{                                              }
{       版权所有 (C) 2004 nil   }
{                                               }
{       2004-6-10                       }
{                                               }
{************************}


{
    通常将TTracer的实例存放于application级的Session中,在使用时,
    创建一个ITraceInfo,调用TTracer.Write(ITraceInfo)即可,
}

unit com.sunset.app.tracer;

interface

uses StrUtils,classes,SysUtils;

type

//==========================
// 接口声明
//==========================

    //跟踪信息的接口
    ITraceInfo = interface
        function ToString: string;
    end;
    //输出目标的接口
    IOutput = interface
        procedure Write(const aInfo: ITraceInfo); //写入跟踪信息
    end;

//==========================
// 跟踪信息类 ,实现 ITraceInfo
//==========================

    //string形式的跟踪记录
    TStringTI = class(TInterfacedObject, ITraceInfo)
    private
        FData: string;
    public
        constructor Create(data: string);
        function ToString: string;
    end;

//==========================
// 跟踪信息输出类,实现 IOutput
//==========================




    TFileLog = class(TInterfacedObject, IOutput)
    private
        FLogFile: string;
    public
        constructor Create(const FileName: string);
        procedure Write(const aInfo: ITraceInfo); //写入跟踪信息
    end;

    TProcStr = procedure(const value:string) of Object;
    TDatabaseLog = class(TInterfacedObject, IOutput)
    private
        FWriteProc :TProcStr;