Beispiel #1
0
void initial_logging(std::string filename_prefix)
{

    InitializeLogger(StringPrintf("%s.INFO", filename_prefix.c_str()),
            StringPrintf("%s.WARN", filename_prefix.c_str()),
            StringPrintf("%s.ERROR", filename_prefix.c_str()));
}
Beispiel #2
0
int main( int argc, char **argv ) {

	//Initialize easylogging
	InitializeLogger();

	//TODO - Use boost cmdline args

	if( argc < 3 )
	{
		DisplayUsage();

		return EXIT_FAILURE;
	}
	else
	{
		std::unique_ptr<CMultiTrackerApp> trackerApp( new CMultiTrackerApp( argv ) );

		if( !trackerApp->Initialize() )
		{
			LOG( INFO ) << ">>>> Application Failed To Initialize <<<<";
			return false;
		}

		trackerApp->Run();

		LOG( INFO ) << ">>>> Application Closing <<<<";

		return EXIT_SUCCESS;
	}
}
/*
Name: main
Description: this is the main entry point of the application. It will just call other functions to do the activity
Parameters: argc - Argument count - It will have only 1 - application name
			argv - values of the argument passed - it will have only application name
ReturnValue: 0 for success else error codes
*/
int main(int argc, char** argv)
{
	int nReturnValue = 0;
	char szMessage[1024] = { '\0' };

	printf("\nBHS:INFO:Started BASIC HTTP SERVER.....\n");
	printf_s("\nBHS:INFO:Started reading server configuraiton file\n");
	nReturnValue = ConfigFileParserInitialization();
	if (nReturnValue != 0)
	{
		printf_s("\nBHS:ERROR:Initialization of configuraition file reading failed with error:%d\n", nReturnValue);
		return nReturnValue;
	}
	nReturnValue = ReadConfigurationFile();
	if (nReturnValue != 0)
	{
		printf_s("\nBHS:ERROR:Error in reading configuraiton file = %d\n", nReturnValue);
		return nReturnValue;
	}
	nReturnValue = InitializeLogger();
	//printf("\nBHS:INFO:Initializing Socket......\n");
	if (nReturnValue != 0)
	{
		printf("\nBHS:ERROR:Initialization of logger failed... ending the server: %d\n", nReturnValue);
		//sprintf_s(szMessage, 1024, "Initialization of logger failed... ending the server: %d\n", nReturnValue);
		//LogMessage(LOG_ERROR, szMessage);
		UninitializeConfigurationParameters();
		return nReturnValue;
	}

	nReturnValue = InitializeSocket();
	if (nReturnValue != 0)
	{
		//printf_s("BHS:ERROR:Error has occured during initialization of socket\n");
		sprintf_s(szMessage, 1024, "BHS:ERROR:Error has occured during initialization of socket %d", nReturnValue);
		LogMessage(LOG_ERROR, szMessage);
	}
	else
	{
		//printf("\nBHS:INFO:Finished Socket initialization......\n");
		//printf("\nBHS:INFO:Started listening for client socket connection.......\n");
		nReturnValue = ListenForClientConnection();
		if (nReturnValue != 0)
		{
			printf_s("BHS:ERROR:ERROR has occurred during listening to client connection\n");
		}
	}

	printf_s("\nBHS:INFO:Uninitializing the parameters configured after reading configuration files\n");
	nReturnValue = UninitializeConfigurationParameters();
	if (nReturnValue != 0)
	{
		printf_s("\nBHS:ERROR:error during uninitializing the parameters: %d\n", nReturnValue);
	}
	printf("\nBHS:INFO:Exiting BASIC HTTP SERVER.......\n");

	nReturnValue = UninitializeLogger();

	return nReturnValue;
}
Beispiel #4
0
// 应用程序初始化
BOOL CUpdaterApp::InitInstance()
{
	// 确保单进程
	if (thePid.IsExist()) return FALSE;

	// 日志记录
	InitializeLogger();

	// 命令行参数
	if (_InitCmdline(__argc, __targv))
	{
		// 是否开启更新
		CConfigFile conf(_T("Setting.ini"));
		CString strAllow;
		conf.GetKeyString(_T("Update"), _T("Allow"), _T("true"), strAllow);
		if (!strAllow.CompareNoCase(_T("true")))
		{
			// 服务器
			conf.GetKeyString(_T("Update"), _T("ServerAddress"), _T(""), m_szServer, 511);
			int nLen = lstrlen(m_szServer);
			if (nLen > 0)
			{
				if (m_szServer[nLen - 1] == _T('/'))
				{
					m_szServer[nLen - 1] = _T('\0');
				}

				// 初始化下载列表
				if (_InitFileList())
				{
					// 等待进程结束,需主进程自己结束
					HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, m_dwProcessId);
					TCHAR szExeFile[512] = {0};
					GetModuleFileNameEx(hProcess, NULL, szExeFile, 511);

					// 检查是否需要更新
					if (_CheckNeedUpdate())
					{
						WaitForSingleObject(hProcess, INFINITE);
						CloseHandle(hProcess);

						// 开始更新
						CUpdaterDlg dlg;
						dlg.DoModal();

						// 启动大厅
						ShellExecute(NULL, _T("Open"), szExeFile, NULL, NULL, SW_SHOW);
					}
					else
					{
						// 已是最新或者主进程未允许更新
						if (IsWindow(m_hWindowCtrl))
						{
							PostMessage(m_hWindowCtrl, UM_NONEEDUPDATE, 0, 0);
						}
					}
				}
				else
				{
					LOG(_T("初始化下载列表失败"));
					if (IsWindow(m_hWindowCtrl))
					{
						PostMessage(m_hWindowCtrl, UM_CHECKFILEERROR, 0, 0);
					}
				}
			}
			else
			{
				LOG(_T("未配置更新地址!"));
				if (IsWindow(m_hWindowCtrl))
				{
					PostMessage(m_hWindowCtrl, UM_DISABLEUPDATE, 0, 0);
				}
			}
		}
		else
		{
			LOG(_T("未开启更新!"));
			if (IsWindow(m_hWindowCtrl))
			{
				PostMessage(m_hWindowCtrl, UM_DISABLEUPDATE, 0, 0);
			}
		}
	}
	else
	{
		LOG(_T("初始化命令行失败!"));
	}

	return FALSE;
}