资源简介
多线程日志记录源码
多线程日志记录源码
多线程日志记录源码
代码片段和文件信息
// InfomationReport.cpp: implementation of the CInfoReport class.
//
//////////////////////////////////////////////////////////////////////
#include “stdafx.h“
#include “WriteInfo.h“
#include “InfomationReport.h“
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
// 因为是static member,所以要在此声明
CPtrList CInfoReport::m_lstpThreads;
DWORD CInfoReport::m_dwFatalErrThrdID;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CInfoReport::CInfoReport()
{
}
CInfoReport::~CInfoReport()
{
}
//////////////////////////////////////////////////////////////////
// 功能函数
//////////////////////////////////////////////////////////////////
//
// FUNCTION: DWORD Register(LPCTSTR ModuleNameToReg)
//
// PURPOSE: 根据传入的模块名返回一个ID为调用WriteInfo()作准备
//
// PARAMETERS:
// MoudleNameToReg: 用来获取ID的模块名称。
//
// RETURN VALUE:
// DWORD类型,实际上是所分配线程在lstpThreads链表中的存储位置。
//
// COMMENTS:
//
// 当需要日志记录时,需要用该函数取得一个ID来调用WriteInfo()。
// 该函数给出一个新的ID意味着为调用它的模块产生了一个新的日志记录线程。
//
DWORD CInfoReport::Register(LPCTSTR ModuleNameToReg)
{
CWriteInfo *pWriteInfo = NULL;
POSITION pos posPrev;
// 首先要起动一个维护FatalErr.log的线程
if(m_lstpThreads.IsEmpty())
{
CString strFatalErr = “FatalErr.log“;
// 为每一个需要注册的模块创建操作对应文件的线程
pWriteInfo = (CWriteInfo*)::AfxBeginThread(RUNTIME_CLASS(CWriteInfo)00CREATE_SUSPENDED);
pWriteInfo->SetModuleFileName(strFatalErr);
m_dwFatalErrThrdID = (DWORD)m_lstpThreads.AddTail(pWriteInfo);
pWriteInfo->ResumeThread();
}
// 当遇到在一个模块内重复调用该函数这种情况时仍然返回原有的ID即对应线程在m_lstpThreads中的position即可
pos = m_lstpThreads.GetHeadPosition();
while(pos)
{
posPrev = pos;
pWriteInfo = (CWriteInfo*)m_lstpThreads.GetNext(pos);
if(0 == pWriteInfo->GetName().CompareNoCase(ModuleNameToReg))
//if(ModuleNameToReg == pWriteInfo->GetName())
{
return (DWORD)posPrev;
}
}
// 为每一个需要注册的模块创建或者打开操作对应的文件
{
}
// 为每一个需要注册的模块创建操作对应文件的线程
pWriteInfo = (CWriteInfo*)::AfxBeginThread(RUNTIME_CLASS(CWriteInfo)00CREATE_SUSPENDED);
pWriteInfo->SetModuleFileName(ModuleNameToReg);
pos = m_lstpThreads.AddTail(pWriteInfo);
pWriteInfo->ResumeThread();
return (DWORD)pos;
}
//////////////////////////////////////////////////////////////////
// 功能函数
//////////////////////////////////////////////////////////////////
//
// FUNCTION: void WriteInfo(DWORD MoudleID CString InfoDescribe)
//
// PURPOSE: 将提供的信息写入到对应的日志文件中。
//
// PARAMETERS:
// MoudleID: 用Register()函数获取来的模块ID如果以NULL作为MoudleID来调
// 用此函数那就意味着发生了致命错误信息将被写入到FatalErr.log文件中。
// InfoDescribe: 需要记录的信息
//
// RETURN VALUE:
// N/A
//
// COMMENTS:
//
// 用该函数写入日志信息。
//
void CInfoReport::WriteInfo(DWORD MoudleID CString InfoDescribe)
{
/* // 如果以NULL作为MoudleID来调用此函数那就意味着发生了致命错误.
if(MoudleID == NULL)
MoudleID = m_dwFatalErrThrdID;
*/
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1277 2007-06-14 10:13 InfoReportDemo多线程日志记录good\Include\InfomationReport.h
文件 5458 2007-06-14 12:25 InfoReportDemo多线程日志记录good\InfoReport\InfomationReport.cpp
文件 1561 2003-05-28 15:03 InfoReportDemo多线程日志记录good\InfoReport\InfoReport.cpp
文件 196 2003-05-28 15:03 InfoReportDemo多线程日志记录good\InfoReport\InfoReport.def
文件 4539 2007-06-14 13:31 InfoReportDemo多线程日志记录good\InfoReport\InfoReport.dsp
文件 543 2003-05-28 15:03 InfoReportDemo多线程日志记录good\InfoReport\InfoReport.dsw
文件 58368 2007-06-14 13:52 InfoReportDemo多线程日志记录good\InfoReport\InfoReport.ncb
文件 54784 2007-06-14 13:52 InfoReportDemo多线程日志记录good\InfoReport\InfoReport.opt
文件 256 2007-06-14 13:52 InfoReportDemo多线程日志记录good\InfoReport\InfoReport.plg
文件 3089 2003-05-28 15:03 InfoReportDemo多线程日志记录good\InfoReport\InfoReport.rc
文件 51 2003-06-02 10:47 InfoReportDemo多线程日志记录good\InfoReport\res\CVS\Entries
文件 23 2003-06-02 10:47 InfoReportDemo多线程日志记录good\InfoReport\res\CVS\Repository
文件 46 2003-06-02 10:47 InfoReportDemo多线程日志记录good\InfoReport\res\CVS\Root
文件 402 2003-05-28 15:03 InfoReportDemo多线程日志记录good\InfoReport\res\InfoReport.rc2
文件 382 2003-05-28 15:03 InfoReportDemo多线程日志记录good\InfoReport\Resource.h
文件 212 2003-05-28 15:03 InfoReportDemo多线程日志记录good\InfoReport\StdAfx.cpp
文件 1485 2003-05-28 15:03 InfoReportDemo多线程日志记录good\InfoReport\StdAfx.h
文件 4511 2007-06-14 13:51 InfoReportDemo多线程日志记录good\InfoReport\WriteInfo.cpp
文件 1580 2003-05-29 14:25 InfoReportDemo多线程日志记录good\InfoReport\WriteInfo.h
文件 1965 2003-06-12 17:14 InfoReportDemo多线程日志记录good\InfoReportTest\InfoReportTest.clw
文件 4468 2007-06-14 12:37 InfoReportDemo多线程日志记录good\InfoReportTest\InfoReportTest.cpp
文件 4914 2007-06-14 12:47 InfoReportDemo多线程日志记录good\InfoReportTest\InfoReportTest.dsp
文件 551 2003-06-12 17:14 InfoReportDemo多线程日志记录good\InfoReportTest\InfoReportTest.dsw
文件 1444 2003-06-12 17:14 InfoReportDemo多线程日志记录good\InfoReportTest\InfoReportTest.h
文件 66560 2007-06-14 13:52 InfoReportDemo多线程日志记录good\InfoReportTest\InfoReportTest.ncb
文件 55808 2007-06-14 13:52 InfoReportDemo多线程日志记录good\InfoReportTest\InfoReportTest.opt
文件 838 2007-06-14 13:52 InfoReportDemo多线程日志记录good\InfoReportTest\InfoReportTest.plg
文件 9997 2003-06-12 17:14 InfoReportDemo多线程日志记录good\InfoReportTest\InfoReportTest.rc
文件 1902 2003-06-12 17:14 InfoReportDemo多线程日志记录good\InfoReportTest\InfoReportTestDoc.cpp
文件 1563 2003-06-12 17:14 InfoReportDemo多线程日志记录good\InfoReportTest\InfoReportTestDoc.h
............此处省略34个文件信息
- 上一篇:C#调用PComm.dll
- 下一篇:Asp.net多线程
相关资源
- c# 高校档案信息管理系统
- asp.net中c#做的躲避小游戏,希望大家
- ASP.NET C# 工资管理系统
- ASP.NET客户管理系统(毕业设计 C#
- 在线求职系统(C#ASP.NET源码)
- asp.net 在线考试系统及论文
- ASP.Net文件上传管理源码
- 《OA企业办公自动化》asp.net 源码(附
- asp.netc#开发规范
- asp.net 大文件上传(带进度条)
- 通过程序自动填充并提交ASP.NET表单(
- ASP.NET 基础编程文档(PPT电子教案)
-
ASP.NET_xm
l深入编程技术 - asp.net 新闻发布系统源码(附文档以及
- asp.net 简单的Ajax应用
- asp.net 企业官网源码(附数据库)
- asp.net 花语花店销售网站源码(含数据
- ASP.NET资产管理系统源码(附数据库)
- ajax 登录(基于asp.net)
- asp.net 简单新闻发布系统源码(附数据
- asp.net新闻发布系统(源码+数据库+论
- asp.net网上购物系统源码
- ASP.NET 在浏览器中预览文件
- asp.net 生命周期
- asp.net 花语花店销售网站源码(附数据
- asp.net 购物车实现(基于Session)
- C# asp.net验证码
- asp.net 网上商城源码
- 小区物业管理系统源码 asp.net物业管理
- ASP.NET程序开发范例宝典 百度云
评论
共有 条评论