mirror of https://github.com/Icinga/icinga2.git
parent
78140fa1c8
commit
bc83c9a698
|
@ -328,6 +328,7 @@ int Main(void)
|
|||
&GlobalArgumentCompletion, true, autoindex);
|
||||
rc = 0;
|
||||
} else if (command) {
|
||||
Logger::DisableTimestamp(true);
|
||||
#ifndef _WIN32
|
||||
if (command->GetImpersonationLevel() == ImpersonateRoot) {
|
||||
if (getuid() != 0) {
|
||||
|
|
|
@ -36,6 +36,7 @@ INITIALIZE_ONCE(&Logger::StaticInitialize);
|
|||
std::set<Logger::Ptr> Logger::m_Loggers;
|
||||
boost::mutex Logger::m_Mutex;
|
||||
bool Logger::m_ConsoleLogEnabled = true;
|
||||
bool Logger::m_TimestampEnabled = true;
|
||||
LogSeverity Logger::m_ConsoleLogSeverity = LogInformation;
|
||||
|
||||
void Logger::StaticInitialize(void)
|
||||
|
@ -198,3 +199,13 @@ LogSeverity Logger::GetConsoleLogSeverity(void)
|
|||
{
|
||||
return m_ConsoleLogSeverity;
|
||||
}
|
||||
|
||||
void Logger::DisableTimestamp(bool disable)
|
||||
{
|
||||
m_TimestampEnabled = !disable;
|
||||
}
|
||||
|
||||
bool Logger::IsTimestampEnabled(void)
|
||||
{
|
||||
return m_TimestampEnabled;
|
||||
}
|
||||
|
|
|
@ -83,6 +83,8 @@ public:
|
|||
|
||||
static void DisableConsoleLog(void);
|
||||
static bool IsConsoleLogEnabled(void);
|
||||
static void DisableTimestamp(bool);
|
||||
static bool IsTimestampEnabled(void);
|
||||
|
||||
static void SetConsoleLogSeverity(LogSeverity logSeverity);
|
||||
static LogSeverity GetConsoleLogSeverity(void);
|
||||
|
@ -97,6 +99,7 @@ private:
|
|||
static boost::mutex m_Mutex;
|
||||
static std::set<Logger::Ptr> m_Loggers;
|
||||
static bool m_ConsoleLogEnabled;
|
||||
static bool m_TimestampEnabled;
|
||||
static LogSeverity m_ConsoleLogSeverity;
|
||||
};
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ void StreamLogger::BindStream(std::ostream *stream, bool ownsStream)
|
|||
|
||||
m_Stream = stream;
|
||||
m_OwnsStream = ownsStream;
|
||||
|
||||
|
||||
m_FlushLogTimer = make_shared<Timer>();
|
||||
m_FlushLogTimer->SetInterval(1);
|
||||
m_FlushLogTimer->OnTimerExpired.connect(boost::bind(&StreamLogger::FlushLogTimerHandler, this));
|
||||
|
@ -98,7 +98,8 @@ void StreamLogger::ProcessLogEntry(std::ostream& stream, const LogEntry& entry)
|
|||
|
||||
boost::mutex::scoped_lock lock(m_Mutex);
|
||||
|
||||
stream << "[" << timestamp << "] ";
|
||||
if (Logger::IsTimestampEnabled())
|
||||
stream << "[" << timestamp << "] ";
|
||||
|
||||
int color;
|
||||
|
||||
|
@ -137,4 +138,3 @@ void StreamLogger::ProcessLogEntry(const LogEntry& entry)
|
|||
{
|
||||
ProcessLogEntry(*m_Stream, entry);
|
||||
}
|
||||
|
||||
|
|
|
@ -312,6 +312,9 @@ std::vector<String> DaemonCommand::GetArgumentSuggestions(const String& argument
|
|||
*/
|
||||
int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::string>& ap) const
|
||||
{
|
||||
if (!vm.count("validate"))
|
||||
Logger::DisableTimestamp(false);
|
||||
|
||||
ScriptVariable::Set("UseVfork", true, false, true);
|
||||
|
||||
Application::MakeVariablesConstant();
|
||||
|
|
Loading…
Reference in New Issue