]> granicus.if.org Git - icinga2/commitdiff
Remove the ConsoleLogger class and keep the default console log enabled until we...
authorGunnar Beutner <gunnar@beutner.name>
Mon, 16 Dec 2013 16:05:23 +0000 (17:05 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Mon, 16 Dec 2013 16:23:23 +0000 (17:23 +0100)
Refs #5342

doc/3.10-logging.md
doc/4.3-object-types.md
icinga-app/icinga.cpp
lib/base/CMakeLists.txt
lib/base/consolelogger.cpp [deleted file]
lib/base/consolelogger.h [deleted file]
lib/base/consolelogger.ti [deleted file]
lib/base/logger.cpp
lib/base/logger.h
lib/config/base-type.conf

index 97327988807ad7a55a074be1c9e1738870c288b2..051f671eadf6196c1a741f0429132a82f622e688 100644 (file)
@@ -25,13 +25,3 @@ and forward the `debug` serverity into an Icinga 2 debug file.
       path = "/var/log/icinga2/debug.log"
     }
 
-If you're starting Icinga 2 not as daemon, but in foreground
-using `/usr/sbin/icinga2 -c /etc/icinga2/icinga2.conf` you may
-want to enable console logging temporary too.
-
-    object ConsoleLogger "debug-console" {
-      severity = "debug"
-    }
-
-
-
index e9ddef1c0e23d333db2a757a75d3c91515a95eee..5edce0b093cab9e8f1fb6def601b950625771acc 100644 (file)
@@ -350,22 +350,6 @@ Attributes:
   duration        |**Optional.** How long the downtime lasts. Only has an effect for flexible (non-fixed) downtimes.
   ranges          |**Required.** A dictionary containing information which days and durations apply to this timeperiod.
 
-### <a id="objecttype-consolelogger"></a> ConsoleLogger
-
-Specifies Icinga 2 logging to the console.
-
-Example:
-
-    object ConsoleLogger "my-debug-console" {
-      severity = "debug"
-    }
-
-Attributes:
-
-  Name            |Description
-  ----------------|----------------
-  severity        |**Optional.** The minimum severity for this log. Can be "debug", "information", "warning" or "critical". Defaults to "information".
-
 ### <a id="objecttype-filelogger"></a> FileLogger
 
 Specifies Icinga 2 logging to a file.
index 01313ead6294a2b4f36e654248b00a4e525feb5e..5995dc1b686821a33ecc2ecdd87b99c7505c58e2 100644 (file)
@@ -21,7 +21,7 @@
 #include "config/configcompiler.h"
 #include "config/configitembuilder.h"
 #include "base/application.h"
-#include "base/logger_fwd.h"
+#include "base/logger.h"
 #include "base/timer.h"
 #include "base/utility.h"
 #include "base/exception.h"
@@ -370,6 +370,7 @@ int main(int argc, char **argv)
                        errorLog = g_AppParams["errorlog"].as<String>();
 
                Daemonize(errorLog);
+               Logger::DisableConsoleLog();
        }
 
        bool validateOnly = g_AppParams.count("validate");
index ac59e58d0aefed3d1f4a0d4a76126084f2ce454c..e9f027abc1f103141e2150585fe15ac5fe8d6b0d 100644 (file)
@@ -16,7 +16,6 @@
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
 mkclass_target(application.ti application.th)
-mkclass_target(consolelogger.ti consolelogger.th)
 mkclass_target(dynamicobject.ti dynamicobject.th)
 mkclass_target(filelogger.ti filelogger.th)
 mkclass_target(logger.ti logger.th)
@@ -25,17 +24,17 @@ mkclass_target(streamlogger.ti streamlogger.th)
 mkclass_target(sysloglogger.ti sysloglogger.th)
 
 add_library(base SHARED
-  application.cpp application.th array.cpp bufferedstream.cpp consolelogger.cpp
-  consolelogger.th context.cpp convert.cpp dictionary.cpp dynamicobject.cpp
-  dynamicobject.th dynamictype.cpp exception.cpp fifo.cpp filelogger.cpp
-  filelogger.th logger.cpp logger.th netstring.cpp networkstream.cpp object.cpp
-  objectlock.cpp process.cpp process-unix.cpp process-windows.cpp qstring.cpp
-  ringbuffer.cpp script.cpp script.th scriptfunction.cpp scriptfunctionwrapper.cpp
-  scriptinterpreter.cpp scriptlanguage.cpp scriptvariable.cpp serializer.cpp
-  socket.cpp stacktrace.cpp stdiostream.cpp stream_bio.cpp stream.cpp
-  streamlogger.cpp streamlogger.th sysloglogger.cpp sysloglogger.th tcpsocket.cpp
-  threadpool.cpp timer.cpp tlsstream.cpp tlsutility.cpp type.cpp unixsocket.cpp
-  utility.cpp value.cpp workqueue.cpp zlibstream.cpp
+  application.cpp application.th array.cpp bufferedstream.cpp context.cpp
+  convert.cpp dictionary.cpp dynamicobject.cpp dynamicobject.th dynamictype.cpp
+  exception.cpp fifo.cpp filelogger.cpp filelogger.th logger.cpp logger.th
+  netstring.cpp networkstream.cpp object.cpp objectlock.cpp process.cpp
+  process-unix.cpp process-windows.cpp qstring.cpp ringbuffer.cpp script.cpp
+  script.th scriptfunction.cpp scriptfunctionwrapper.cpp scriptinterpreter.cpp
+  scriptlanguage.cpp scriptvariable.cpp serializer.cpp socket.cpp stacktrace.cpp
+  stdiostream.cpp stream_bio.cpp stream.cpp streamlogger.cpp streamlogger.th
+  sysloglogger.cpp sysloglogger.th tcpsocket.cpp threadpool.cpp timer.cpp
+  tlsstream.cpp tlsutility.cpp type.cpp unixsocket.cpp utility.cpp value.cpp
+  workqueue.cpp zlibstream.cpp
 )
 
 target_link_libraries(base ${CMAKE_DL_LIBS} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} cJSON mmatch)
diff --git a/lib/base/consolelogger.cpp b/lib/base/consolelogger.cpp
deleted file mode 100644 (file)
index 3a47b3a..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/******************************************************************************
- * Icinga 2                                                                   *
- * Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)   *
- *                                                                            *
- * This program is free software; you can redistribute it and/or              *
- * modify it under the terms of the GNU General Public License                *
- * as published by the Free Software Foundation; either version 2             *
- * of the License, or (at your option) any later version.                     *
- *                                                                            *
- * This program is distributed in the hope that it will be useful,            *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
- * GNU General Public License for more details.                               *
- *                                                                            *
- * You should have received a copy of the GNU General Public License          *
- * along with this program; if not, write to the Free Software Foundation     *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
- ******************************************************************************/
-
-#include "base/consolelogger.h"
-#include "base/dynamictype.h"
-#include <iostream>
-
-using namespace icinga;
-
-REGISTER_TYPE(ConsoleLogger);
-
-/**
- * Constructor for the ConsoleLogger class.
- */
-void ConsoleLogger::Start()
-{
-       StreamLogger::Start();
-
-       BindStream(&std::cout, false);
-}
diff --git a/lib/base/consolelogger.h b/lib/base/consolelogger.h
deleted file mode 100644 (file)
index 8e8306d..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/******************************************************************************
- * Icinga 2                                                                   *
- * Copyright (C) 2012-2013 Icinga Development Team (http://www.icinga.org/)   *
- *                                                                            *
- * This program is free software; you can redistribute it and/or              *
- * modify it under the terms of the GNU General Public License                *
- * as published by the Free Software Foundation; either version 2             *
- * of the License, or (at your option) any later version.                     *
- *                                                                            *
- * This program is distributed in the hope that it will be useful,            *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
- * GNU General Public License for more details.                               *
- *                                                                            *
- * You should have received a copy of the GNU General Public License          *
- * along with this program; if not, write to the Free Software Foundation     *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
- ******************************************************************************/
-
-#ifndef CONSOLELOGGER_H
-#define CONSOLELOGGER_H
-
-#include "base/i2-base.h"
-#include "base/consolelogger.th"
-
-namespace icinga
-{
-
-/**
- * A logger that logs to the console.
- *
- * @ingroup base
- */
-class I2_BASE_API ConsoleLogger : public ObjectImpl<ConsoleLogger>
-{
-public:
-       DECLARE_PTR_TYPEDEFS(ConsoleLogger);
-
-       virtual void Start(void);
-};
-
-}
-
-#endif /* CONSOLELOGGER_H */
diff --git a/lib/base/consolelogger.ti b/lib/base/consolelogger.ti
deleted file mode 100644 (file)
index 4059f45..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "base/streamlogger.h"
-
-namespace icinga
-{
-
-class ConsoleLogger : StreamLogger
-{
-};
-
-}
\ No newline at end of file
index c3ce6e24da5fc7fe1d0c6722563a8aa7e757d914..a703944adbe78a2300e6d99e0120d5b24d499c28 100644 (file)
@@ -35,6 +35,7 @@ REGISTER_TYPE(Logger);
 
 std::set<Logger::Ptr> Logger::m_Loggers;
 boost::mutex Logger::m_Mutex;
+bool Logger::m_ConsoleLogEnabled = true;
 
 /**
  * Constructor for the Logger class.
@@ -85,20 +86,14 @@ void icinga::Log(LogSeverity severity, const String& facility,
                }
        }
 
-       bool processed = false;
-
        BOOST_FOREACH(const Logger::Ptr& logger, Logger::GetLoggers()) {
-               {
-                       ObjectLock llock(logger);
-
-                       if (!logger->IsActive())
-                               continue;
+               ObjectLock llock(logger);
 
-                       if (entry.Severity >= logger->GetMinSeverity())
-                               logger->ProcessLogEntry(entry);
-               }
+               if (!logger->IsActive())
+                       continue;
 
-               processed = true;
+               if (entry.Severity >= logger->GetMinSeverity())
+                       logger->ProcessLogEntry(entry);
        }
 
        LogSeverity defaultLogLevel;
@@ -108,7 +103,7 @@ void icinga::Log(LogSeverity severity, const String& facility,
        else
                defaultLogLevel = LogInformation;
 
-       if (!processed && entry.Severity >= defaultLogLevel) {
+       if (Logger::IsConsoleLogEnabled() && entry.Severity >= defaultLogLevel) {
                static bool tty = StreamLogger::IsTty(std::cout);
 
                StreamLogger::ProcessLogEntry(std::cout, tty, entry);
@@ -168,3 +163,14 @@ LogSeverity Logger::StringToSeverity(const String& severity)
        else
                BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid severity: " + severity));
 }
+
+void Logger::DisableConsoleLog(void)
+{
+       m_ConsoleLogEnabled = false;
+}
+
+bool Logger::IsConsoleLogEnabled(void)
+{
+       return m_ConsoleLogEnabled;
+}
+
index ca656ffd4c09e266f6f4af2f4a51fdf01fcf6643..854c14d66814ef12806a32780e122ac197b940eb 100644 (file)
@@ -66,6 +66,9 @@ public:
 
        static std::set<Logger::Ptr> GetLoggers(void);
 
+       static void DisableConsoleLog(void);
+       static bool IsConsoleLogEnabled(void);
+
 protected:
        virtual void Start(void);
        virtual void Stop(void);
@@ -73,6 +76,7 @@ protected:
 private:
        static boost::mutex m_Mutex;
        static std::set<Logger::Ptr> m_Loggers;
+       static bool m_ConsoleLogEnabled;
 
        friend void Log(LogSeverity severity, const String& facility,
            const String& message);
index fb6001bc948d61f7492fba1bf2b56e84dc112607..063843e57400a5c7f9560ecb258654b6e0b23a92 100644 (file)
@@ -43,9 +43,6 @@ type Logger {
        %attribute string "severity"
 }
 
-type ConsoleLogger inherits Logger {
-}
-
 type FileLogger inherits Logger {
        %require "path",
        %attribute string "path"