示例#1
0
LogManager::LogManager()
{
    for (size_t i = 0; i < max_logs; ++i)
    {
        slot[i].index = i;
        slot[i].log = &g_null_log;
    }

    SetLog(new StdoutLogger, stdout_log);
    SetLog(new StdoutLogger, app_log);
    SetLog(new StdoutLogger, debug_log);
    slot[stdout_log].title = _T("stdout");
    slot[app_log].title = _T("Code::Blocks");
    slot[debug_log].title = _T("Code::Blocks Debug");

    ColourManager *manager = Manager::Get()->GetColourManager();
    manager->RegisterColour(_("Logs"), _("Success text"), wxT("logs_success_text"), *wxBLUE);
    manager->RegisterColour(_("Logs"), _("Warning text"), wxT("logs_warning_text"), *wxBLUE);
    manager->RegisterColour(_("Logs"), _("Error text"), wxT("logs_error_text"), wxColour(0xf0, 0x00, 0x00));
    manager->RegisterColour(_("Logs"), _("Critical text"), wxT("logs_critical_text"), *wxWHITE);
    manager->RegisterColour(_("Logs"), _("Critical background"), wxT("logs_critical_back"), *wxRED);
    manager->RegisterColour(_("Logs"), _("Critical text (ListCtrl)"),
                            wxT("logs_critical_text_listctrl"), wxColour(0x0a, 0x00, 0x00));
    manager->RegisterColour(_("Logs"), _("Failure text"), wxT("logs_failure_text"), wxColour(0x00, 0x00, 0xa0));

    Register(_T("null"),   new Instantiator<NullLogger>);
    Register(_T("stdout"), new Instantiator<StdoutLogger>);
    Register(_T("text"),   new Instantiator<TextCtrlLogger>);
    Register(_T("file"),   new Instantiator<FileLogger, true>);
}
示例#2
0
LogManager::LogManager()
{
    for(size_t i = 0; i < max_logs; ++i)
    {
        slot[i].index = i;
        slot[i].log = &g_null_log;
    }

    SetLog(new StdoutLogger, stdout_log);
    SetLog(new StdoutLogger, app_log);
    SetLog(new StdoutLogger, debug_log);
    slot[stdout_log].title = _T("stdout");
    slot[app_log].title = _T("Em::Blocks");
    slot[debug_log].title = _T("Em::Blocks Debug");

    Register(_T("null"),   new Instantiator<NullLogger>);
    Register(_T("stdout"), new Instantiator<StdoutLogger>);
    Register(_T("text"),   new Instantiator<TextCtrlLogger>);
    Register(_T("file"),   new Instantiator<FileLogger, true>);
}
示例#3
0
int main(int argc, char* argv[])
{
  argc -= handleOpts(argc, argv);
  if (argc < 2){
    fprintf(stderr, usage, argv[0]);
    exit(1);
  }
  optClientno = atoi(argv[optind+1]);

  ConfigParser cp(argv[optind]);
  cp.Parse();
  bool load_complete = false;
  for (auto& section : cp._section_names){
    if (section.find("Workload") != std::string::npos){
      std::string workload = section;

      Config cfg(&cp, workload);
      // SYSTEM-SPECIFIC
      std::string system_conf = cfg.get<std::string>("yesql", "");

      std::string dir = cfg.get<std::string>("logdir", ".");
      LOG("Got %s as logdir", dir.c_str());
      if (dir.back() != '/')
        dir.append("/");
      dir.append("client-");
      dir.append(std::to_string(optClientno));
      dir.append("-");
      dir.append(workload);
      dir.append(".txt");
      LOG("Setting log as %s\n", dir.c_str());
      SetLog(dir.c_str());
      LOG("About to initialize\n");
      if (!load_complete){
        sqlite3_initialize();
// FIXME        SetDebugLevel(0);
      } else {
// FIXME        SetDebugLevel(0);
      }
      int nthreads = cfg.get<int>("threads", 1);
      bool do_load = false;
      if (!load_complete)
        do_load = cfg.get<bool>("load", true);
      LOG("About to do a yesql experiment with %d threads\n", nthreads);
      do_experiment(nthreads, system_conf.c_str(), &cfg, do_load);
      load_complete = true;
    }
  }
  return 0;
}
示例#4
0
CGPSProc::CGPSProc()
{
    WSADATA wsaData;
    WORD     wVersion;
    wVersion = MAKEWORD(2,2);
    
    //申请Socket资源
    int nRes  = WSAStartup(wVersion,&wsaData);//版本信息
    if(nRes != 0)
    {
        WSACleanup();
        TRACE("TcpServer no Sock dll to use!!\n");	
    }
    
    if((LOBYTE(wsaData.wVersion) != 2) || (HIBYTE(wsaData.wVersion) != 2))//查找WINSOCK的DLL
    {
        WSACleanup();
        TRACE("TcpServer no right Sock dll!!\n");
    }
    
    m_bThreadStart = FALSE;
    
    m_dwDataAnalyseThreadID = 0;
    m_hDataAnalyseThread = NULL;
    m_hDataAnalyseThreadEndEvt = NULL;
    
    int i;
    for(i = 0; i < MAX_PUB_PROTOCAL_DOWN; i++)
    {
        m_nAckCount[i] = 0;
    }
    
    memset(m_LocalIpAddress,0,MAX_IPADDRESS_LEN);
    
//    m_MppOLD.InitRoutineServer(MAX_PUBLICNET_CLIENT_CONNECT);
    
    
    m_bStartFlag = FALSE;
	m_IsIOCPActive = FALSE;
    
    
    InitFieldStatisticTable();

    SetLog();
}
示例#5
0
int main(int argc, char* argv[])
{
  argc -= handleOpts(argc, argv);
  if (argc < 2){
    fprintf(stderr, "Usage: %s [config.ini]\n", argv[0]);
    exit(1);
  }
  optClientno = atoi(argv[optind+1]);

  ConfigParser cp(argv[optind]);
  cp.Parse();

  for (auto& section : cp._sections){
    if (section.first.find("Workload") != std::string::npos){
      std::string workload = section.first;

      Config cfg(&cp, workload);
      // SYSTEM-SPECIFIC
      std::string system_conf;
      if (!optServerPort) system_conf = cfg.get<std::string>("yesql", "");
      else system_conf = std::string(optServerPort);

      std::string dir = cfg.get<std::string>("logdir", ".");
      if (dir.back() != '/')
        dir.append("/");
      dir.append("client-");
      dir.append(std::to_string(optClientno));
      dir.append("-");
      dir.append(workload);
      dir.append(".txt");
      SetLog(dir.c_str());
      LOG("Starting a YESQL expt.\n");
      int nthreads = cfg.get<int>("threads", 1);
      do_experiment(nthreads, system_conf.c_str(), &cfg, false);
    }
  }
  return 0;
}
示例#6
0
/**
 * @ingroup SipSpeed
 * @brief 테스트 결과 이벤트 수신 핸들러
 * @param wParam 
 * @param lParam 
 * @returns 0 을 리턴한다.
 */
LRESULT CSipSpeedDlg::OnTestMessage( WPARAM wParam, LPARAM lParam )
{
	if( wParam == WM_TEST_END )
	{
		double fCps = 0.0;

		if( lParam > 0 )
		{
			fCps = (double)( m_iCallSuccess + m_iCallError ) / ( (double)lParam / 1000 );
		}

		SetLog( "call success(%d) / error(%d) / cps(%.3f) / time(%d ms)", m_iCallSuccess, m_iCallError, fCps, lParam );

		m_bTest = false;

		m_btnStartTest.EnableWindow( TRUE );
		m_btnStopTest.EnableWindow( FALSE );

		gclsSipUserAgent.m_clsSipStack.DeleteCallBack( this );
	}

	return 0;
}
示例#7
0
void LogManager::DeleteLog(int i)
{
    SetLog(&g_null_log, i);
}
示例#8
0
void io_loop()
{
char to_send[200];
time_t lasttime = 0;
long lastrecvK = 0;
int  lrv = 0;
time_t      lasttimeofday;
int delay = 0;

 while(1)
 {
   lasttimeofday = timeofday;

   if ((timeofday = time(NULL)) == -1) 
   {
#ifdef USE_SYSLOG
      syslog(LOG_WARNING, "Clock Failure (%d), TS can be corrupted", errno);
#endif
      sendto_ops("Clock Failure (%d), TS can be corrupted", errno);
   }

   if (timeofday < lasttimeofday) 
   {
      ircsprintf(to_send, "System clock is running backwards - (%d < %d)",
		 timeofday, lasttimeofday);
      report_error(to_send, &me);
   }

   NOW = timeofday;

   /*
    * This chunk of code determines whether or not "life sucks", that
    * is to say if the traffic level is so high that standard server
    * commands should be restricted
    * 
    * Changed by Taner so that it tells you what's going on as well as
    * allows forced on (long LCF), etc...
    */

   if ((timeofday - lasttime) >= LCF) 
   {
      lrv = LRV * LCF;
      lasttime = timeofday;
      currlife = (me.receiveK - lastrecvK) / LCF;
      if ((me.receiveK - lrv) > lastrecvK || HTMLOCK == YES) 
      {
	 if (!lifesux) 
 	 {
	    /*
	     * In the original +th code Taner had
	     * 
	     * LCF << 1;  / * add hysteresis * /
	     * 
	     * which does nothing... so, the hybrid team changed it to
	     * 
	     * LCF <<= 1;  / * add hysteresis * /
	     * 
	     * suddenly, there were reports of clients mysteriously just
	     * dropping off... Neither rodder or I can see why it makes
	     * a difference, but lets try it this way...
	     * 
	     * The original dog3 code, does not have an LCF variable
	     * 
	     * -Dianora
	     * 
	     */
	    lifesux = 1;

	    if (noisy_htm) 
	       sendto_ops("Entering high-traffic mode - (%dk/s > %dk/s)", currlife, LRV);
	 }
	 else 
	 {
	    lifesux++;		/* Ok, life really sucks! */
	    LCF += 2;		/* Wait even longer */
	    if (noisy_htm) 
	       sendto_ops("Still high-traffic mode %d%s (%d delay): %dk/s",
			  lifesux, (lifesux > 9) ? " (TURBO)" : "", (int) LCF, currlife);

	   /* Reset htm here, because its been on a little too long.
	    * Bad Things(tm) tend to happen with HTM on too long -epi */

	    if (lifesux>15) 
	    {
	       if (noisy_htm) 
		  sendto_ops("Resetting HTM and raising limit to: %dk/s\n", LRV + 5);
	       LCF=LOADCFREQ;
	       lifesux=0;
	       LRV+=5;
	    }
	 }
      }
      else 
      {
	 LCF = LOADCFREQ;
	 if (lifesux) 
	 {
	    lifesux = 0;
	    if (noisy_htm)
	       sendto_ops("Resuming standard operation . . . .");
	 }
      }
      lastrecvK = me.receiveK;
   }
   /*
    * * We only want to connect if a connection is due, not every
    * time through.  Note, if there are no active C lines, this call
    * to Tryconnections is made once only; it will return 0. - avalon
    */

   if (nextconnect && timeofday >= nextconnect)
      nextconnect = try_connections(timeofday);

   /* DNS checks. One to timeout queries, one for cache expiries.*/

   if (timeofday >= nextdnscheck)
      nextdnscheck = timeout_query_list(timeofday);
   if (timeofday >= nextexpire)
      nextexpire = expire_cache(timeofday);

   /*
    * * take the smaller of the two 'timed' event times as the time
    * of next event (stops us being late :) - avalon WARNING -
    * nextconnect can return 0!
    */

   if (nextconnect)
      delay = MIN(nextping, nextconnect);
   else
      delay = nextping;
   delay = MIN(nextdnscheck, delay);
   delay = MIN(nextexpire, delay);
   delay -= timeofday;

   /*
    * * Adjust delay to something reasonable [ad hoc values] (one
    * might think something more clever here... --msa) 
    * We don't really need to check that often and as long 
    * as we don't delay too long, everything should be ok. 
    * waiting too long can cause things to timeout... 
    * i.e. PINGS -> a disconnection :( 
    * - avalon
    */
   if (delay < 1)
      delay = 1;
   else
      delay = MIN(delay, TIMESEC);
   /*
    * We want to read servers on every io_loop, as well as "busy"
    * clients (which again, includes servers. If "lifesux", then we
    * read servers AGAIN, and then flush any data to servers. -Taner
    */

#ifndef NO_PRIORITY
   read_message(0, &serv_fdlist);
   read_message(1, &busycli_fdlist);
   if (lifesux) 
   {
      (void) read_message(1, &serv_fdlist);
      if (lifesux > 9) 		/* life really sucks */
      {
	 (void) read_message(1, &busycli_fdlist);
	 (void) read_message(1, &serv_fdlist);
      }
      flush_fdlist_connections(&serv_fdlist);
   }

   if ((timeofday = time(NULL)) == -1) 
   {
	#ifdef USE_SYSLOG
           syslog(LOG_WARNING, "Clock Failure (%d), TS can be corrupted", errno);
	#endif
      sendto_ops("Clock Failure (%d), TS can be corrupted", errno);
   }
   /*
    * CLIENT_SERVER = TRUE: If we're in normal mode, or if "lifesux"
    * and a few seconds have passed, then read everything.
    * CLIENT_SERVER = FALSE: If it's been more than lifesux*2 seconds
    * (that is, at most 1 second, or at least 2s when lifesux is != 0)
    * check everything. -Taner
    */
   { 
      static time_t lasttime = 0;

# ifdef CLIENT_SERVER
      if (!lifesux || (lasttime + lifesux) < timeofday) {
# else
      if ((lasttime + (lifesux + 1)) < timeofday) {
# endif
	 (void) read_message(delay ? delay : 1, NULL);	/* check everything! */
	 lasttime = timeofday;
      }
   }
#else
   (void) read_message(delay, NULL);	/* check everything! */
#endif
   /*
    * * ...perhaps should not do these loops every time, but only if
    * there is some chance of something happening (but, note that
    * conf->hold times may be changed elsewhere--so precomputed next
    * event time might be too far away... (similarly with ping
    * times) --msa
    */

   if ((timeofday >= nextping))
      nextping = check_pings(timeofday);

   if (dorehash && !lifesux) 
   {
      (void) rehash(&me, &me, 1);
      dorehash = 0;
   }
   /*
    * 
    * Flush output buffers on all connections now if they 
    * have data in them (or at least try to flush)  -avalon
    *
    * flush_connections(me.fd);
    *
    * avalon, what kind of crack have you been smoking? why
    * on earth would we flush_connections blindly when
    * we already check to see if we can write (and do)
    * in read_message? There is no point, as this causes
    * lots and lots of unnecessary sendto's which 
    * 99% of the time will fail because if we couldn't
    * empty them in read_message we can't empty them here.
    * one effect: during htm, output to normal lusers
    * will lag.
    */

    /* Now we've made this call a bit smarter. */
    /* Only flush non-blocked sockets. */

    flush_connections(me.fd);

#ifndef NO_PRIORITY
   check_fdlists();
#endif

#ifdef	LOCKFILE
   /*
    * * If we have pending klines and CHECK_PENDING_KLINES minutes
    * have passed, try writing them out.  -ThemBones
    */

   if ((pending_klines) && ((timeofday - pending_kline_time)
			    >= (CHECK_PENDING_KLINES * 60)))
      do_pending_klines();
#endif
 }
}
/*
 * open_debugfile
 * 
 * If the -t option is not given on the command line when the server is
 * started, all debugging output is sent to the file set by LPATH in
 * config.h Here we just open that file and make sure it is opened to
 * fd 2 so that any fprintf's to stderr also goto the logfile.  If the
 * debuglevel is not set from the command line by -x, use /dev/null as
 * the dummy logfile as long as DEBUGMODE has been defined, else dont
 * waste the fd.
 */
static void
open_debugfile()
{
#ifdef	DEBUGMODE
int         fd;
aClient    *cptr;

   if (debuglevel >= 0) 
   {
      cptr = make_client(NULL, NULL);
      cptr->fd = 2;
      SetLog(cptr);
      cptr->port = debuglevel;
      cptr->flags = 0;
      cptr->acpt = cptr;
      local[2] = cptr;
      (void) strcpy(cptr->sockhost, me.sockhost);

      (void) printf("isatty = %d ttyname = %#x\n",
		    isatty(2), (u_int) ttyname(2));
      if (!(bootopt & BOOT_TTY)) 	/*) leave debugging output on fd */ 
      {
	 (void) truncate(LOGFILE, 0);
	 if ((fd = open(LOGFILE, O_WRONLY | O_CREAT, 0600)) < 0)
	    if ((fd = open("/dev/null", O_WRONLY)) < 0)
	       exit(-1);
	 if (fd != 2) 
    	 {
	    (void) dup2(fd, 2);
	    (void) close(fd);
	 }
	 strncpyzt(cptr->name, LOGFILE, sizeof(cptr->name));
      }
      else if (isatty(2) && ttyname(2))
	 strncpyzt(cptr->name, ttyname(2), sizeof(cptr->name));
      else
	 (void) strcpy(cptr->name, "FD2-Pipe");
      Debug((DEBUG_FATAL, "Debug: File <%s> Level: %d at %s",
	     cptr->name, cptr->port, myctime(time(NULL))));
   }
   else
      local[2] = NULL;
#endif
   return;
}
/**
 * @ingroup SipSpeed
 * @brief SIP REGISTER 응답 메시지 수신 이벤트 핸들러
 * @param pclsInfo	SIP REGISTER 응답 메시지를 전송한 IP-PBX 정보 저장 객체
 * @param iStatus		SIP REGISTER 응답 코드
 */
void CSipSpeedDlg::_EventRegister( CSipServerInfo * pclsInfo, int iStatus )
{
	std::string	strCommand;

	if( pclsInfo->m_bLogin )
	{
		strCommand = "login";
	}
	else
	{
		strCommand = "logout";
	}

	if( !strcmp( pclsInfo->m_strUserId.c_str(), m_strCallerId ) )
	{
		if( iStatus == SIP_OK )
		{
			if( pclsInfo->m_bLogin )
			{
				m_bCallerLogin = true;
			}
			else
			{
				m_bCallerLogin = false;
			}

			SetLog( "Caller(%s) %s success", m_strCallerId, strCommand.c_str() );
		}
		else
		{
			m_bCallerLogin = false;
			SetLog( "Caller(%s) %s error(%d)", m_strCallerId, strCommand.c_str(), iStatus );
		}
	}
	else if( !strcmp( pclsInfo->m_strUserId.c_str(), m_strCalleeId ) )
	{
		if( iStatus == SIP_OK )
		{
			if( pclsInfo->m_bLogin )
			{
				m_bCalleeLogin = true;
			}
			else
			{
				m_bCalleeLogin = false;
			}

			SetLog( "Callee(%s) %s success", m_strCalleeId, strCommand.c_str() );
		}
		else
		{
			m_bCalleeLogin = false;
			SetLog( "Callee(%s) %s error(%d)", m_strCalleeId, strCommand.c_str(), iStatus );
		}
	}

	// Caller, Callee 가 모두 로그인되면 테스트를 시작할 수 있다.
	if( pclsInfo->m_bLogin && m_bCallerLogin && m_bCalleeLogin )
	{
		if( m_bTest == false )
		{
			m_btnStartTest.EnableWindow( TRUE );
		}
	}
}
示例#10
0
 // Clear log resource to avoid crash during caught abnormal termination
 void ClearLogResource( ) { SetLog (NULL, GetDiagBase( )); }