Przeglądaj źródła

add OutputDebugStringLoggingChannel

Kolja Strohm 6 miesięcy temu
rodzic
commit
e83a8a72ea
2 zmienionych plików z 35 dodań i 6 usunięć
  1. 14 2
      Logging.cpp
  2. 21 4
      Logging.h

+ 14 - 2
Logging.cpp

@@ -562,7 +562,19 @@ Framework::Logging::CoutLoggingChannel::CoutLoggingChannel()
 
 void Framework::Logging::CoutLoggingChannel::writeMessage(const Text& msg) const
 {
-    std::cout << msg.getText();
+    std::cout << msg.getText() << std::endl;
+}
+
+Framework::Logging::OutputDebugStringLoggingChannel::
+    OutputDebugStringLoggingChannel()
+    : LoggingChannel()
+{}
+
+void Framework::Logging::OutputDebugStringLoggingChannel::writeMessage(
+    const Text& msg) const
+{
+    OutputDebugStringA(msg.getText());
+    OutputDebugStringA("\n");
 }
 
 Framework::Logging::ConsoleHandlerLoggingChannel::ConsoleHandlerLoggingChannel(
@@ -694,4 +706,4 @@ void Framework::Logging::LoggingHandler::log(
     {
         channel->writeMessage(message, level, location);
     }
-}
+}

+ 21 - 4
Logging.h

@@ -285,8 +285,27 @@ namespace Framework
              * writes a message to the std::cout.
              *
              * \param msg the message
-             * \param level the log level
-             * \param location the location of the call
+             */
+            DLLEXPORT virtual void writeMessage(const Text& msg) const override;
+        };
+
+        /**
+         * logs messages to OutputDebugString.
+         */
+        class OutputDebugStringLoggingChannel : public LoggingChannel
+        {
+        public:
+            /**
+             * creates a new cout logging channel.
+             *
+             */
+            DLLEXPORT OutputDebugStringLoggingChannel();
+
+        protected:
+            /**
+             * writes a message to OutputDebugString.
+             *
+             * \param msg the message
              */
             DLLEXPORT virtual void writeMessage(const Text& msg) const override;
         };
@@ -313,8 +332,6 @@ namespace Framework
              * writes a message to the given ConsoleHandler.
              *
              * \param msg the message
-             * \param level the log level
-             * \param location the location of the call
              */
             DLLEXPORT virtual void writeMessage(const Text& msg) const override;
         };