Exemplo n.º 1
0
// Overloaded version that takes a STL::string
void CFileLogger::Log(const std::string strText, eLogLevel iLogLevel, ...)
{
  va_list       args;  

  if ((m_strFilenamePath.length() > 0) && 
      (m_iLogLevel <= iLogLevel))
  {
    FILE* fp = NULL;
    fp = fopen(m_strFilenamePath.c_str(), "a");

    std::string strTimeStamp = GetTimeDateStamp();

    if (fp != NULL)
    {
      std::string strIndented = strTimeStamp + GetIndentedString(strText) + "\n";

      va_start(args, iLogLevel);
      vfprintf(fp, strIndented.c_str(), args);
      va_end(args);

      // Optionally we can output message to stdout
      if (m_bOutputScreen)
      {
        va_start(args, iLogLevel);
        vprintf(strIndented.c_str(), args);
        va_end(args);
      }

      fclose(fp);
      fp = NULL;
    }
  }
}
Exemplo n.º 2
0
BOOL COXHistoryCtrl::AddStampedLine(CString string, 
									BOOL bAddToLog/*=TRUE*/)
{
	CString sStampedString=GetTimeDateStamp()+_T(" ")+string;
	BOOL bReturn=AddLine(sStampedString,bAddToLog);

	return bReturn;
}
Exemplo n.º 3
0
// Version that assume log level is logCRITICAL
void CFileLogger::LogCritical(const char* szText, ...)
{
  // Note: it would be nice not to duplicate code, but the variable
  // parameter list makes this problematic.
  va_list       args;  

  // Always log critical messages
  if ((m_strFilenamePath.length() > 0) &&
      (szText != NULL))
  {
    FILE* fp = NULL;
    fp = fopen(m_strFilenamePath.c_str(), "a");

    std::string strTimeStamp = GetTimeDateStamp();

    if (fp != NULL)
    {
      std::string strIndented = strTimeStamp + GetIndentedString(szText) + "\n";

      va_start(args, szText);
      vfprintf(fp, strIndented.c_str(), args);
      va_end(args);

      // Optionally we can output message to stdout
      if (m_bOutputScreen)
      {
        va_start(args, szText);
        vprintf(strIndented.c_str(), args);
        va_end(args);
      }

      fclose(fp);
      fp = NULL;
    }
  }
}