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

Delphi
在线播放器DIY
关于VisiBroker For Delphi的使用(3)
关于VisiBroker For Delphi的使用(2)
关于VisiBroker For Delphi的使用(1)
Delphi的两个实用技巧(2)巧用Windows的API函数
Delphi的两个实用技巧(1)播放Flash
delphi学习:两种方法使用xml文档
Delphi与Word之间的融合技术
Delphi中动态链接库(DLL)的建立和使用
Delphi基础:Window 消息大全使用详解下
Delphi基础:Window 消息大全使用详解上
教你在DELPHI中如何调用系统对话框
Delphi开发单机瘦小数据库程序要点
用Delphi + DirectX开发简单RPG游戏
Delphi7从入门到精通之认识Delphi编辑器
Delphi7从入门到精通之历数Delphi七个版本
Delphi学习:图像放大漫游攻略
用编程来实现24小时制到12小时制的转换
一个实际的OLE服务器的开发
Delphi一点通:如何将源代码学好

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-30   浏览: 86 ::
收藏到网摘: 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;