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.

67 lines
2.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. //fclose(stderr);
  14. m_pCL = new objectConsoleLoggingService();
  15. if ( m_pCL ) m_pLog->addHandler( m_pCL );
  16. pSetting = config_setting_get_member( m_pSP, "USE_LOG_FILE" );
  17. if ( pSetting != NULL ) {
  18. if (config_setting_get_bool(pSetting) ) {
  19. char mLogFileName[128];
  20. pSetting = config_setting_get_member(m_pSP, "LOG_FILE_NAME");
  21. if (pSetting != NULL) {
  22. sprintf(mLogFileName, "%s", config_setting_get_string(pSetting));
  23. } else {
  24. sprintf(mLogFileName, "mekorot.log" );
  25. pSetting = config_setting_add(m_pSP, "LOG_FILE_NAME", CONFIG_TYPE_STRING);
  26. basicSettingsProvider::getInstance()->compromise();
  27. if (pSetting == NULL) {
  28. LOG_ERROR("Failure while adding setting!");
  29. return -1;
  30. };
  31. config_setting_set_string(pSetting, mLogFileName);
  32. };
  33. m_pFL = new objectFileLoggingService( mLogFileName );
  34. if ( m_pFL == NULL) {
  35. LOG_ERROR("Failure open log file!");
  36. } else {
  37. m_pLog->addHandler( m_pFL );
  38. };
  39. };
  40. } else {
  41. pSetting = config_setting_add( m_pSP, "USE_LOG_FILE", CONFIG_TYPE_BOOL);
  42. basicSettingsProvider::getInstance()->compromise();
  43. if (pSetting == NULL) {
  44. LOG_ERROR("Failure while adding setting!");
  45. return -1;
  46. };
  47. };
  48. m_pKRNL = new mekorotKernel();
  49. if (m_pKRNL != NULL) {
  50. if (m_pKRNL->init()) {
  51. m_pKRNL->waitThreadEnd();
  52. } else {
  53. LOG_ERROR("Failure during Kernel Thread Start!");
  54. };
  55. } else {
  56. LOG_ERROR("Failure during Kernel Construct!");
  57. };
  58. basicSettingsProvider::getInstance()->validate();
  59. return 0;
  60. }
  61. #undef LOG
  62. #undef LOG_ERROR