You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.8 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. // MEKOROT.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3. #include "MEKOROT.h"
  4. #define LOG( X ) m_pLog->Log( "main", NULL, X )
  5. #define LOG_ERROR( X ) m_pLog->Log( "main", NULL, _LOG_ERROR, X )
  6. int main(){
  7. basicLogCollection * m_pLog = basicLogCollection::getInstance();
  8. objectConsoleLoggingService * m_pCL;
  9. objectFileLoggingService * m_pFL;
  10. config_setting_t * m_pSP = basicSettingsProvider::getInstance((CSTR)"mekorot.conf")->getSubNode(NULL, (CSTR)"GENERAL");
  11. config_setting_t * pSetting = NULL;
  12. mekorotKernel * m_pKRNL;
  13. m_pCL = new objectConsoleLoggingService();
  14. if ( m_pCL ) m_pLog->addHandler( m_pCL );
  15. pSetting = config_setting_get_member( m_pSP, "USE_LOG_FILE" );
  16. if ( pSetting != NULL ) {
  17. if (config_setting_get_bool(pSetting) ) {
  18. char mLogFileName[128];
  19. pSetting = config_setting_get_member(m_pSP, "LOG_FILE_NAME");
  20. if (pSetting != NULL) {
  21. sprintf(mLogFileName, "%s", config_setting_get_string(pSetting));
  22. } else {
  23. sprintf(mLogFileName, "mekorot.log" );
  24. pSetting = config_setting_add(m_pSP, "LOG_FILE_NAME", CONFIG_TYPE_STRING);
  25. basicSettingsProvider::getInstance()->compromise();
  26. if (pSetting == NULL) {
  27. LOG_ERROR("Failure while adding setting!");
  28. return -1;
  29. };
  30. config_setting_set_string(pSetting, mLogFileName);
  31. };
  32. m_pFL = new objectFileLoggingService( mLogFileName );
  33. if ( m_pFL == NULL) {
  34. LOG_ERROR("Failure open log file!");
  35. } else {
  36. m_pLog->addHandler( m_pFL );
  37. };
  38. };
  39. } else {
  40. pSetting = config_setting_add( m_pSP, "USE_LOG_FILE", CONFIG_TYPE_BOOL);
  41. basicSettingsProvider::getInstance()->compromise();
  42. if (pSetting == NULL) {
  43. LOG_ERROR("Failure while adding setting!");
  44. return -1;
  45. };
  46. };
  47. m_pKRNL = new mekorotKernel();
  48. if (m_pKRNL != NULL) {
  49. if (m_pKRNL->init()) {
  50. m_pKRNL->waitThreadEnd();
  51. } else {
  52. LOG_ERROR("Failure during Kernel Thread Start!");
  53. };
  54. } else {
  55. LOG_ERROR("Failure during Kernel Construct!");
  56. };
  57. basicSettingsProvider::getInstance()->validate();
  58. return 0;
  59. }
  60. #undef LOG
  61. #undef LOG_ERROR
  62. // Run program: Ctrl + F5 or Debug > Start Without Debugging menu
  63. // Debug program: F5 or Debug > Start Debugging menu
  64. // Tips for Getting Started:
  65. // 1. Use the Solution Explorer window to add/manage files
  66. // 2. Use the Team Explorer window to connect to source control
  67. // 3. Use the Output window to see build output and other messages
  68. // 4. Use the Error List window to view errors
  69. // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
  70. // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file