变长参数的函数写法

//*****************************************************************************************
//                Template No. SWF0012   Template Version No. 04.04.00
//
//*****************************************************************************************
//   FUNCTION NAME    : PrintLog()
//
//-------------------------------------------------- PURPOSE -----------------------------------------
//
//     Print a text in log file
//---------------------------------------- $$ REQUIREMENTS $$ ----------------------------------------
//
//  Format: $${TAG} R[#][Prod. ID]:Specification Path
//
//               $$:    ISGcq00622453
//                TAG:    [APP_GEN]
//              R #:    R[29]
//            Prod.ID: 
//        Spec. Path:   /vob/
//
//
//
//-------------------- PSEUDO CODE / DETAILED FUNCTION DESCRIPTION -------------------
//
//            Creates a log file with the phone info
//
//------------------------------------------------ REVISIONS ------------------------------------------
// Date       Name                 Tracking #     Description
// ---------  -------------------  -------------  ------------------------------
// 26ARP2011  Feng Liu             ISGcq00622453  Initial Creation
//*****************************************************************************************************
//
//----------------------------------------- FUNCTION DEFINITION ---------------------------------------
void FeatureDisableDlg::PrintLog(CString& message)
{
    if(APPLICATION_VERSION[0] != 'R')
    {
        try
        {
            //verify if it is already opened
            if (m_logFile.m_hFile == CFile::hFileNull)
            {
                if(m_logFile.Open(LOG_FILE_NAME,
                        CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite))
                {
                    m_logFile.SeekToEnd();
                    CString log;
                    log.Format("=====================================================/n",log);
                    time_t rawtime;
                    time ( &rawtime );
                    char timeStr[0x100];

                    if(!ctime_s(timeStr, 0x100, &rawtime)) {
                        log.Format("Execution date: %s", timeStr);
                    } else {
                        log.Format("Execution date: %s", "Can not read the time.");
                    }

                    m_logFile.Write(log, log.GetLength());
                }
            }
            m_logFile.Write(message, message.GetLength());
        }
        catch (...)
        {
        }
    }
}void FeatureDisableDlg::PrintLog(const char* message, ...)
{
//  if(APPLICATION_VERSION[0] != 'R')
  if(1)
  {
      va_list list;
      va_start(list, message);
      char szBuffer[MAX_OUTPUT_TEXT_SIZE];
      _vsnprintf_s(szBuffer, sizeof(szBuffer), message, list);

      CString log(szBuffer);
      PrintLog(log);

      va_end(list);
  }
}

发表于 @ 2011年04月26日 10:13:00 | 评论( 0 ) | 编辑| 举报| 收藏

本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/asiainfolf/archive/2011/04/26/6363397.aspx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值