mirror of https://github.com/Icinga/icinga2.git
parent
cb1caf560b
commit
7cedb381b8
|
@ -54,17 +54,17 @@ String TroubleshootCollectCommand::GetShortDescription(void) const
|
||||||
class TroubleshootCollectCommand::InfoLog
|
class TroubleshootCollectCommand::InfoLog
|
||||||
{
|
{
|
||||||
bool console;
|
bool console;
|
||||||
std::ofstream os;
|
std::ostream *os;
|
||||||
public:
|
public:
|
||||||
InfoLog(const String& path, const bool cons)
|
InfoLog(const String& path, const bool cons)
|
||||||
{
|
{
|
||||||
console = cons;
|
console = cons;
|
||||||
if (console) {
|
if (console) {
|
||||||
os.copyfmt(std::cout);
|
os = new std::ostream(std::cout.rdbuf());
|
||||||
os.clear(std::cout.rdstate());
|
|
||||||
os.basic_ios<char>::rdbuf(std::cout.rdbuf());
|
|
||||||
} else {
|
} else {
|
||||||
os.open(path.CStr(), std::ios::out | std::ios::trunc);
|
std::ofstream *ofs = new std::ofstream();
|
||||||
|
ofs->open(path.CStr(), std::ios::out | std::ios::trunc);
|
||||||
|
os = ofs;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,16 +74,16 @@ public:
|
||||||
Log(sev, "troubleshoot", str);
|
Log(sev, "troubleshoot", str);
|
||||||
|
|
||||||
if (sev == LogCritical || sev == LogWarning) {
|
if (sev == LogCritical || sev == LogWarning) {
|
||||||
os << std::string(24, '#') << '\n'
|
*os << std::string(24, '#') << '\n'
|
||||||
<< "# " << str << '\n'
|
<< "# " << str << '\n'
|
||||||
<< std::string(24, '#') << '\n';
|
<< std::string(24, '#') << '\n';
|
||||||
} else
|
} else
|
||||||
os << str << '\n';
|
*os << str << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetStreamHealth()
|
bool GetStreamHealth()
|
||||||
{
|
{
|
||||||
return console || os.is_open();
|
return *os;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue