Пример #1
0
/*************************************************************************
	Legend window selected agent changed!
*************************************************************************/
void System::onLegendSelectChanged(int idSelectAgent, CAgentInfo_LogDlg* pLogDlg, CAgentInfo_InfoDlg* pInfoDlg)
{
	//check 
	Agent* pAgent = m_pAgentManager->findAgent(idSelectAgent);
	if(!pAgent) return;

	//------------------------------------------
	//multi thread lock
	lockLog();

	//------------------------------------------
	//clean old log
	pLogDlg->clearAllLog();
	pInfoDlg->clearAllLog();

	m_idSelectAgent = idSelectAgent;

	//dump all log of this agent
	if(pAgent->getLog())
	{
		pAgent->getLog()->dumpLog(pLogDlg);
	}

	//------------------------------------------
	//multi thread Unlock
	unlockLog();
}
Пример #2
0
//------------------------------------------------------------------------------
static void log(const char *string)
{
   // Bail if we ain't logging.
   if (!consoleLogMode) 
   {
      return;
   }

   // In mode 1, we open, append, close on each log write.
   if ((consoleLogMode & 0x3) == 1) 
   {
      consoleLogFile.open(defLogFileName, Torque::FS::File::ReadWrite);
   }

   // Write to the log if its status is hunky-dory.
   if ((consoleLogFile.getStatus() == Stream::Ok) || (consoleLogFile.getStatus() == Stream::EOS)) 
   {
      consoleLogFile.setPosition(consoleLogFile.getStreamSize());
      // If this is the first write...
      if (newLogFile) 
      {
         // Make a header.
         Platform::LocalTime lt;
         Platform::getLocalTime(lt);
         char buffer[128];
         dSprintf(buffer, sizeof(buffer), "//-------------------------- %d/%d/%d -- %02d:%02d:%02d -----\r\n",
               lt.month + 1,
               lt.monthday,
               lt.year + 1900,
               lt.hour,
               lt.min,
               lt.sec);
         consoleLogFile.write(dStrlen(buffer), buffer);
         newLogFile = false;
         if (consoleLogMode & 0x4) 
         {
            // Dump anything that has been printed to the console so far.
            consoleLogMode -= 0x4;
            U32 size, line;
            ConsoleLogEntry *log;
            getLockLog(log, size);
            for (line = 0; line < size; line++) 
            {
               consoleLogFile.write(dStrlen(log[line].mString), log[line].mString);
               consoleLogFile.write(2, "\r\n");
            }
            unlockLog();
         }
      }
      // Now write what we came here to write.
      consoleLogFile.write(dStrlen(string), string);
      consoleLogFile.write(2, "\r\n");
   }

   if ((consoleLogMode & 0x3) == 1) 
   {
      consoleLogFile.close();
   }
}