Refactor code

fixes #9112
This commit is contained in:
Jean-Marcel Flach 2015-04-20 11:01:27 +02:00 committed by Gunnar Beutner
parent e1101b9637
commit 9ae8a09b7e
2 changed files with 5 additions and 5 deletions

View File

@ -253,14 +253,14 @@ bool TroubleshootCommand::ConfigInfo(InfoLog& log, const boost::program_options:
InfoLogLine(log) InfoLogLine(log)
<< "A collection of important configuration files follows, please make sure to remove any sensitive data such as credentials, internal company names, etc\n"; << "A collection of important configuration files follows, please make sure to remove any sensitive data such as credentials, internal company names, etc\n";
if (!PrintConf(log, Application::GetSysconfDir() + "/icinga2/icinga2.conf")) { if (!PrintFile(log, Application::GetSysconfDir() + "/icinga2/icinga2.conf")) {
InfoLogLine(log, 0, LogWarning) InfoLogLine(log, 0, LogWarning)
<< "icinga2.conf not found, therefore skipping validation.\n" << "icinga2.conf not found, therefore skipping validation.\n"
<< "If you are using an icinga2.conf somewhere but the default path please validate it via 'icinga2 daemon -C -c \"path\to/icinga2.conf\"'\n" << "If you are using an icinga2.conf somewhere but the default path please validate it via 'icinga2 daemon -C -c \"path\to/icinga2.conf\"'\n"
<< "and provide it with your support request.\n"; << "and provide it with your support request.\n";
} }
if (!PrintConf(log, Application::GetSysconfDir() + "/icinga2/zones.conf")) { if (!PrintFile(log, Application::GetSysconfDir() + "/icinga2/zones.conf")) {
InfoLogLine(log, 0, LogWarning) InfoLogLine(log, 0, LogWarning)
<< "zones.conf not found.\n" << "zones.conf not found.\n"
<< "If you are using a zones.conf somewhere but the default path please provide it with your support request\n"; << "If you are using a zones.conf somewhere but the default path please provide it with your support request\n";
@ -410,7 +410,7 @@ bool TroubleshootCommand::PrintCrashReports(InfoLog& log)
InfoLogLine(log) InfoLogLine(log)
<< "Latest crash report is from " << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S", Utility::GetTime()) << '\n' << "Latest crash report is from " << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S", Utility::GetTime()) << '\n'
<< "File: " << bestFilename << "\n\n"; << "File: " << bestFilename << "\n\n";
PrintConf(log, bestFilename); PrintFile(log, bestFilename);
InfoLogLine(log) InfoLogLine(log)
<< '\n'; << '\n';
} }
@ -418,7 +418,7 @@ bool TroubleshootCommand::PrintCrashReports(InfoLog& log)
return true; return true;
} }
bool TroubleshootCommand::PrintConf(InfoLog& log, const String& path) bool TroubleshootCommand::PrintFile(InfoLog& log, const String& path)
{ {
std::ifstream text; std::ifstream text;
text.open(path.CStr(), std::ifstream::in); text.open(path.CStr(), std::ifstream::in);

View File

@ -58,7 +58,7 @@ private:
static bool CheckFeatures(InfoLog& log); static bool CheckFeatures(InfoLog& log);
static void GetLatestReport(const String& filename, time_t& bestTimestamp, String& bestFilename); static void GetLatestReport(const String& filename, time_t& bestTimestamp, String& bestFilename);
static bool PrintCrashReports(InfoLog& log); static bool PrintCrashReports(InfoLog& log);
static bool PrintConf(InfoLog& log, const String& path); static bool PrintFile(InfoLog& log, const String& path);
static bool CheckConfig(void); static bool CheckConfig(void);
static void CheckObjectFile(const String& objectfile, InfoLog& log, InfoLog *OFile, const bool objectConsole, static void CheckObjectFile(const String& objectfile, InfoLog& log, InfoLog *OFile, const bool objectConsole,
Dictionary::Ptr& logs, std::set<String>& configs); Dictionary::Ptr& logs, std::set<String>& configs);