("config,c", po::value<std::vector<std::string> >(), "parse a configuration file")
("no-config,z", "start without a configuration file")
("validate,C", "exit after validating the configuration")
- ("debug,x", po::value<std::string>(), "enable debugging with severity level specified")
+ ("log-level,x", po::value<std::string>(), "specify the log level for the console log")
("errorlog,e", po::value<std::string>(), "log fatal errors to the specified log file (only works in combination with --daemonize)")
#ifndef _WIN32
("reload-internal", po::value<int>(), "used internally to implement config reload: do not call manually, send SIGHUP instead")
}
#endif /* _WIN32 */
- if (g_AppParams.count("debug")) {
- Application::SetDebugging(true);
-
- LogSeverity debug_severity;
- try {
- debug_severity = Logger::StringToSeverity(g_AppParams["debug"].as<std::string>());
- } catch (std::exception&) {
- //not set, use default
- debug_severity = LogDebug;
- }
-
- Application::SetDebuggingSeverity(debug_severity);
+ if (g_AppParams.count("log-level")) {
+ LogSeverity logLevel = Logger::StringToSeverity(g_AppParams["log-level"].as<std::string>());
+ Logger::SetConsoleLogSeverity(logLevel);
}
if (g_AppParams.count("help") || g_AppParams.count("version")) {
bool Application::m_RequestReopenLogs = false;
pid_t Application::m_ReloadProcess = 0;
static bool l_Restarting = false;
-bool Application::m_Debugging = false;
-LogSeverity Application::m_DebuggingSeverity = LogDebug;
int Application::m_ArgC;
char **Application::m_ArgV;
double Application::m_StartTime;
}
#endif /* _WIN32 */
-#ifdef _WIN32
- if (IsDebuggerPresent())
- m_Debugging = true;
-#endif /* _WIN32 */
-
ASSERT(m_Instance == NULL);
m_Instance = this;
}
#endif /* _WIN32 */
}
-/**
- * Sets whether debugging is enabled.
- *
- * @param debug Whether to enable debugging.
- */
-void Application::SetDebugging(bool debug)
-{
- m_Debugging = debug;
-}
-
-/**
- * Retrieves the debugging mode of the application.
- *
- * @returns true if the application is being debugged, false otherwise
- */
-bool Application::IsDebugging(void)
-{
- return m_Debugging;
-}
-
-/**
- * Sets debugging severity.
- *
- * @param severity Debug log severity.
- */
-void Application::SetDebuggingSeverity(LogSeverity severity)
-{
- Application::m_DebuggingSeverity = severity;
-}
-
-/**
- * Retrieves the debugging severity of the application.
- *
- * @returns severity 'debug' if not set, severity value otherwise.
- */
-LogSeverity Application::GetDebuggingSeverity(void)
-{
- if (!Application::m_DebuggingSeverity)
- return LogDebug;
-
- return Application::m_DebuggingSeverity;
-}
-
/**
* Display version information.
*/
static void RequestRestart(void);
static void RequestReopenLogs(void);
- static void SetDebugging(bool debug);
- static bool IsDebugging(void);
-
static void SetDebuggingSeverity(LogSeverity severity);
static LogSeverity GetDebuggingSeverity(void);
std::set<Logger::Ptr> Logger::m_Loggers;
boost::mutex Logger::m_Mutex;
bool Logger::m_ConsoleLogEnabled = true;
+LogSeverity Logger::m_ConsoleLogSeverity = LogInformation;
void Logger::StaticInitialize(void)
{
logger->ProcessLogEntry(entry);
}
- LogSeverity defaultLogLevel;
-
- if (Application::IsDebugging())
- defaultLogLevel = Application::GetDebuggingSeverity();
- else
- defaultLogLevel = LogInformation;
-
- if (Logger::IsConsoleLogEnabled() && entry.Severity >= defaultLogLevel) {
+ if (Logger::IsConsoleLogEnabled() && entry.Severity >= Logger::GetConsoleLogSeverity()) {
static bool tty = StreamLogger::IsTty(std::cout);
StreamLogger::ProcessLogEntry(std::cout, tty, entry);
return m_ConsoleLogEnabled;
}
+void Logger::SetConsoleLogSeverity(LogSeverity logSeverity)
+{
+ m_ConsoleLogSeverity = logSeverity;
+}
+
+LogSeverity Logger::GetConsoleLogSeverity(void)
+{
+ return m_ConsoleLogSeverity;
+}
\ No newline at end of file
static void DisableConsoleLog(void);
static bool IsConsoleLogEnabled(void);
+ static void SetConsoleLogSeverity(LogSeverity logSeverity);
+ static LogSeverity GetConsoleLogSeverity(void);
+
static void StaticInitialize(void);
protected:
static boost::mutex m_Mutex;
static std::set<Logger::Ptr> m_Loggers;
static bool m_ConsoleLogEnabled;
+ static LogSeverity m_ConsoleLogSeverity;
friend I2_BASE_API void Log(LogSeverity severity, const String& facility,
const String& message);
char *jsonString;
- if (Application::IsDebugging())
- jsonString = cJSON_Print(json);
- else
- jsonString = cJSON_PrintUnformatted(json);
+#ifdef _DEBUG
+ jsonString = cJSON_Print(json);
+#else /* _DEBUG */
+ jsonString = cJSON_PrintUnformatted(json);
+#endif /* _DEBUG */
cJSON_Delete(json);