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
67 lines
2.2 KiB
// MEKOROT.cpp : This file contains the 'main' function. Program execution begins and ends there.
|
|
//
|
|
#include "MEKOROT.h"
|
|
|
|
#define LOG( X ) m_pLog->Log( "main", NULL, X )
|
|
#define LOG_ERROR( X ) m_pLog->Log( "main", NULL, _LOG_ERROR, X )
|
|
|
|
int main(){
|
|
basicLogCollection * m_pLog = basicLogCollection::getInstance();
|
|
objectConsoleLoggingService * m_pCL;
|
|
objectFileLoggingService * m_pFL;
|
|
config_setting_t * m_pSP = basicSettingsProvider::getInstance((CSTR)"mekorot.conf")->getSubNode(NULL, (CSTR)"GENERAL");
|
|
config_setting_t * pSetting = NULL;
|
|
mekorotKernel * m_pKRNL;
|
|
|
|
//fclose(stderr);
|
|
|
|
m_pCL = new objectConsoleLoggingService();
|
|
if ( m_pCL ) m_pLog->addHandler( m_pCL );
|
|
pSetting = config_setting_get_member( m_pSP, "USE_LOG_FILE" );
|
|
if ( pSetting != NULL ) {
|
|
if (config_setting_get_bool(pSetting) ) {
|
|
char mLogFileName[128];
|
|
pSetting = config_setting_get_member(m_pSP, "LOG_FILE_NAME");
|
|
if (pSetting != NULL) {
|
|
sprintf(mLogFileName, "%s", config_setting_get_string(pSetting));
|
|
} else {
|
|
sprintf(mLogFileName, "mekorot.log" );
|
|
pSetting = config_setting_add(m_pSP, "LOG_FILE_NAME", CONFIG_TYPE_STRING);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
if (pSetting == NULL) {
|
|
LOG_ERROR("Failure while adding setting!");
|
|
return -1;
|
|
};
|
|
config_setting_set_string(pSetting, mLogFileName);
|
|
};
|
|
m_pFL = new objectFileLoggingService( mLogFileName );
|
|
if ( m_pFL == NULL) {
|
|
LOG_ERROR("Failure open log file!");
|
|
} else {
|
|
m_pLog->addHandler( m_pFL );
|
|
};
|
|
};
|
|
} else {
|
|
pSetting = config_setting_add( m_pSP, "USE_LOG_FILE", CONFIG_TYPE_BOOL);
|
|
basicSettingsProvider::getInstance()->compromise();
|
|
if (pSetting == NULL) {
|
|
LOG_ERROR("Failure while adding setting!");
|
|
return -1;
|
|
};
|
|
};
|
|
m_pKRNL = new mekorotKernel();
|
|
if (m_pKRNL != NULL) {
|
|
if (m_pKRNL->init()) {
|
|
m_pKRNL->waitThreadEnd();
|
|
} else {
|
|
LOG_ERROR("Failure during Kernel Thread Start!");
|
|
};
|
|
} else {
|
|
LOG_ERROR("Failure during Kernel Construct!");
|
|
};
|
|
basicSettingsProvider::getInstance()->validate();
|
|
return 0;
|
|
}
|
|
|
|
#undef LOG
|
|
#undef LOG_ERROR
|