Commit d638ab41 authored by Aleksandr Bakhshiev's avatar Aleksandr Bakhshiev
Browse files

Log control has been updated

parent 69c5e4d490f4
...@@ -105,7 +105,13 @@ int UAppCore<ApplicationT, EngineControlT, ProjectT, ServerControlT, TestManager ...@@ -105,7 +105,13 @@ int UAppCore<ApplicationT, EngineControlT, ProjectT, ServerControlT, TestManager
programName=projectIniFile("General","ProgramName","Server"); programName=projectIniFile("General","ProgramName","Server");
configsMainPath=projectIniFile("General", "ConfigsMainPath", "../../../Configs/"); configsMainPath=projectIniFile("General", "ConfigsMainPath", "../../../Configs/");
neverSleepOnMMThreadContention=atoi(projectIniFile("General","NeverSleepOnMMThreadContention","0")); neverSleepOnMMThreadContention=atoi(projectIniFile("General","NeverSleepOnMMThreadContention","0"));
logDir=projectIniFile("Log","Dir",""); logDir=projectIniFile("Log","Dir",""); // TODO: Log/FixedLogPath
if(logDir.empty())
logDir=projectIniFile("Log","FixedLogPath",""); // TODO: Log/Dir
int logCreationMode=atoi(projectIniFile("Log","LogCreationMode","0"));
// bool SetFixedLogPath(const std::string& value);
startupDelay=atoi(projectIniFile("General","StartupDelay","0")); startupDelay=atoi(projectIniFile("General","StartupDelay","0"));
useNewXmlFormatProjectFile=atoi(projectIniFile("General","UseNewXmlFormatProjectFile","0")); useNewXmlFormatProjectFile=atoi(projectIniFile("General","UseNewXmlFormatProjectFile","0"));
...@@ -121,10 +127,18 @@ int UAppCore<ApplicationT, EngineControlT, ProjectT, ServerControlT, TestManager ...@@ -121,10 +127,18 @@ int UAppCore<ApplicationT, EngineControlT, ProjectT, ServerControlT, TestManager
disableAdminForm=atoi(projectIniFile("General","DisableAdminForm","0")); disableAdminForm=atoi(projectIniFile("General","DisableAdminForm","0"));
application.SetApplicationFileName(application_file_name); application.SetApplicationFileName(application_file_name);
application.SetLogCreationMode(logCreationMode);
if(logDir.empty()) if(logDir.empty())
{
application.SetFixedLogPath(log_dir);
application.SetLogDir(log_dir); application.SetLogDir(log_dir);
}
else else
{
application.SetFixedLogPath(logDir);
application.SetLogDir(logDir); application.SetLogDir(logDir);
}
application.SetDebugMode(logDebugMode); application.SetDebugMode(logDebugMode);
...@@ -132,7 +146,6 @@ int UAppCore<ApplicationT, EngineControlT, ProjectT, ServerControlT, TestManager ...@@ -132,7 +146,6 @@ int UAppCore<ApplicationT, EngineControlT, ProjectT, ServerControlT, TestManager
application.ChangeUseNewXmlFormatProjectFile(useNewXmlFormatProjectFile); application.ChangeUseNewXmlFormatProjectFile(useNewXmlFormatProjectFile);
application.ChangeUseNewProjectFilesStructure(useNewProjectFilesStructure); application.ChangeUseNewProjectFilesStructure(useNewProjectFilesStructure);
if(argc > 1) if(argc > 1)
application.ProcessCommandLineArgs(argc, argv); application.ProcessCommandLineArgs(argc, argv);
......
...@@ -46,6 +46,7 @@ UApplication::UApplication(void) ...@@ -46,6 +46,7 @@ UApplication::UApplication(void)
ModelsMainPath="../../../Models/"; ModelsMainPath="../../../Models/";
ChangeUseNewXmlFormatProjectFile(false); ChangeUseNewXmlFormatProjectFile(false);
ChangeUseNewProjectFilesStructure(false); ChangeUseNewProjectFilesStructure(false);
LogCreationMode=0;
//SetStandartXMLInCatalog(); //SetStandartXMLInCatalog();
...@@ -86,7 +87,8 @@ bool UApplication::SetWorkDirectory(const std::string& value) ...@@ -86,7 +87,8 @@ bool UApplication::SetWorkDirectory(const std::string& value)
if(WorkDirectory == value) if(WorkDirectory == value)
return true; return true;
WorkDirectory=value; WorkDirectory=value;
UpdateLoggers(); if(FixedLogPath.empty())
UpdateLoggers();
return true; return true;
} }
...@@ -156,7 +158,8 @@ bool UApplication::SetProjectPath(const std::string& value) ...@@ -156,7 +158,8 @@ bool UApplication::SetProjectPath(const std::string& value)
if(ProjectPath == value) if(ProjectPath == value)
return true; return true;
ProjectPath=value; ProjectPath=value;
UpdateLoggers(); if(LogCreationMode == 0 || LogCreationMode == 1)
UpdateLoggers();
// EngineControl->GetEngineStateThread()->CloseEventsLogFile(); // EngineControl->GetEngineStateThread()->CloseEventsLogFile();
CalcAppCaption(); CalcAppCaption();
return true; return true;
...@@ -264,18 +267,53 @@ bool UApplication::SetDebugMode(bool value) ...@@ -264,18 +267,53 @@ bool UApplication::SetDebugMode(bool value)
std::string UApplication::CalcCurrentLogDir(void) const std::string UApplication::CalcCurrentLogDir(void) const
{ {
std::string log_dir; std::string log_dir;
if(Project && Project->GetConfig().OverrideLogParameters && !ProjectPath.empty()) switch(LogCreationMode)
{
case 0:
case 1:
{ {
log_dir=ProjectPath+"EventsLog/"; if(Project && Project->GetConfig().OverrideLogParameters && !ProjectPath.empty())
{
log_dir=ProjectPath+"EventsLog/";
}
else
{
if(FixedLogPath.empty())
{
log_dir=Core_GetLogDir();
if(log_dir.empty())
log_dir=WorkDirectory+"EventsLog/";
}
else
{
log_dir=FixedLogPath;
}
if(!log_dir.empty() && log_dir.find_last_of("\\/") != log_dir.size()-1)
log_dir+="/";
}
} }
else break;
case 2:
case 3:
{ {
log_dir=Core_GetLogDir(); if(FixedLogPath.empty())
if(log_dir.empty()) {
log_dir=WorkDirectory+"EventsLog/"; log_dir=Core_GetLogDir();
if(log_dir.empty())
log_dir=WorkDirectory+"EventsLog/";
}
else
{
log_dir=FixedLogPath;
}
if(!log_dir.empty() && log_dir.find_last_of("\\/") != log_dir.size()-1) if(!log_dir.empty() && log_dir.find_last_of("\\/") != log_dir.size()-1)
log_dir+="/"; log_dir+="/";
} }
break;
}
return log_dir; return log_dir;
} }
...@@ -309,6 +347,43 @@ bool UApplication::IsInit(void) const ...@@ -309,6 +347,43 @@ bool UApplication::IsInit(void) const
{ {
return AppIsInit; return AppIsInit;
} }
///
const std::string& UApplication::GetFixedLogPath(void) const
{
return FixedLogPath;
}
bool UApplication::SetFixedLogPath(const std::string& value)
{
if(FixedLogPath == value)
return true;
FixedLogPath=value;
return true;
}
///
/// 0 - ( Reset )
/// 1 - .
/// 2 - .
/// 3 -
int UApplication::GetLogCreationMode(void) const
{
return LogCreationMode;
}
bool UApplication::SetLogCreationMode(int mode)
{
if(LogCreationMode == mode)
return true;
if(mode<0 || mode>3)
return false;
LogCreationMode=mode;
return true;
}
// -------------------------- // --------------------------
// -------------------------- // --------------------------
...@@ -1217,7 +1292,8 @@ bool UApplication::OpenProject(const std::string &filename) ...@@ -1217,7 +1292,8 @@ bool UApplication::OpenProject(const std::string &filename)
ProjectFileName=extract_file_name(filename); ProjectFileName=extract_file_name(filename);
Project->SetProjectPath(ProjectPath); Project->SetProjectPath(ProjectPath);
Project->ReadFromXml(ProjectXml); Project->ReadFromXml(ProjectXml);
UpdateLoggers(); if(LogCreationMode != 3)
UpdateLoggers();
TProjectConfig config=Project->GetConfig(); TProjectConfig config=Project->GetConfig();
GetCore()->GetLogger(RDK_GLOB_MESSAGE)->SetEventsLogMode(config.EventsLogFlag); GetCore()->GetLogger(RDK_GLOB_MESSAGE)->SetEventsLogMode(config.EventsLogFlag);
......
...@@ -94,6 +94,17 @@ bool AppIsInit; ...@@ -94,6 +94,17 @@ bool AppIsInit;
/// xml ( /Bin/Models) /// xml ( /Bin/Models)
std::list<StandartXMLInCatalog> xmlInCatalog; std::list<StandartXMLInCatalog> xmlInCatalog;
///
///
std::string FixedLogPath;
///
/// 0 - ( ResetChannel StartChannel )
/// 1 - .
/// 2 - .
/// 3 -
int LogCreationMode;
protected: // protected: //
/// ///
UEPtr<URpcDispatcher> RpcDispatcher; UEPtr<URpcDispatcher> RpcDispatcher;
...@@ -186,6 +197,18 @@ bool ChangeUseNewProjectFilesStructure(bool value); ...@@ -186,6 +197,18 @@ bool ChangeUseNewProjectFilesStructure(bool value);
const std::list<StandartXMLInCatalog>& GetStandartXMLInCatalog(void) const; const std::list<StandartXMLInCatalog>& GetStandartXMLInCatalog(void) const;
bool SetStandartXMLInCatalog(void); bool SetStandartXMLInCatalog(void);
///
const std::string& GetFixedLogPath(void) const;
bool SetFixedLogPath(const std::string& value);
///
/// 0 - ( ResetChannel StartChannel )
/// 1 - .
/// 2 - .
/// 3 -
int GetLogCreationMode(void) const;
bool SetLogCreationMode(int mode);
/// ///
const std::string& GetAppCaption(void) const; const std::string& GetAppCaption(void) const;
......
...@@ -263,7 +263,8 @@ void UEngineControl::StartChannel(int channel_index) ...@@ -263,7 +263,8 @@ void UEngineControl::StartChannel(int channel_index)
if(channel_index>=GetNumChannels()) if(channel_index>=GetNumChannels())
return; return;
GetCore()->GetLogger(RDK_GLOB_MESSAGE)->RecreateEventsLogFile(); if(Application && Application->GetLogCreationMode() == 0)
GetCore()->GetLogger(RDK_GLOB_MESSAGE)->RecreateEventsLogFile();
// EngineStateThread->RecreateEventsLogFile(); // EngineStateThread->RecreateEventsLogFile();
switch(ThreadMode) switch(ThreadMode)
{ {
...@@ -377,7 +378,8 @@ void UEngineControl::ResetChannel(int channel_index) ...@@ -377,7 +378,8 @@ void UEngineControl::ResetChannel(int channel_index)
if(channel_index>=GetNumChannels()) if(channel_index>=GetNumChannels())
return; return;
GetCore()->GetLogger(RDK_GLOB_MESSAGE)->RecreateEventsLogFile(); if(Application && Application->GetLogCreationMode() == 0)
GetCore()->GetLogger(RDK_GLOB_MESSAGE)->RecreateEventsLogFile();
// EngineStateThread->RecreateEventsLogFile(); // EngineStateThread->RecreateEventsLogFile();
if(channel_index == -1) if(channel_index == -1)
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment