[SCM] kodi-pvr-hts/master: minor refactoring (separate implementation file), fixed a typo

tiber-guest at users.alioth.debian.org tiber-guest at users.alioth.debian.org
Wed Mar 2 23:01:56 UTC 2016


The following commit has been merged in the master branch:
commit b9306715898f7406ae29eac50a44e6b908c4b4f3
Author: Sam Stenvall <sam.stenvall at nordsoftware.com>
Date:   Fri Jan 8 11:44:47 2016 +0200

    minor refactoring (separate implementation file), fixed a typo

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5c7623b..65e5218 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -62,6 +62,8 @@ set(HTS_SOURCES_TVHEADEND_STATUS
 
 set(HTS_SOURCES_TVHEADEND_UTILITIES
                 src/tvheadend/utilities/Utilities.h
+                src/tvheadend/utilities/Logger.h
+                src/tvheadend/utilities/Logger.cpp
                 src/tvheadend/utilities/AsyncState.cpp
                 src/tvheadend/utilities/AsyncState.h)
                 
diff --git a/src/tvheadend/utilities/Logger.cpp b/src/tvheadend/utilities/Logger.cpp
new file mode 100644
index 0000000..0dc0e0d
--- /dev/null
+++ b/src/tvheadend/utilities/Logger.cpp
@@ -0,0 +1,67 @@
+/*
+ *      Copyright (C) 2005-2015 Team Kodi
+ *      http://kodi.tv
+ *
+ *  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, 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 XBMC; see the file COPYING.  If not, write to
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "Logger.h"
+
+#include <cstdarg>
+
+using namespace tvheadend::utilities;
+
+Logger::Logger()
+{
+
+}
+
+Logger &Logger::GetInstance()
+{
+  static Logger instance;
+  return instance;
+}
+
+void Logger::Log(LogLevel level, const std::string &message, ...)
+{
+  auto &logger = GetInstance();
+
+  char buffer[MESSAGE_BUFFER_SIZE];
+  std::string logMessage = message;
+  std::string prefix = logger.m_prefix;
+
+  // Prepend the prefix when set
+  if (!prefix.empty())
+    logMessage = prefix + " - " + message;
+
+  va_list arguments;
+  va_start(arguments, message);
+  vsprintf(buffer, logMessage.c_str(), arguments);
+  va_end(arguments);
+
+  logger.m_implementation(level, buffer);
+}
+
+void Logger::SetImplementation(LoggerImplementation implementation)
+{
+  m_implementation = implementation;
+}
+
+void Logger::SetPrefix(const std::string &prefix)
+{
+  m_prefix = prefix;
+}
diff --git a/src/tvheadend/utilities/Logger.h b/src/tvheadend/utilities/Logger.h
index 8a04674..1599117 100644
--- a/src/tvheadend/utilities/Logger.h
+++ b/src/tvheadend/utilities/Logger.h
@@ -22,8 +22,6 @@
 
 #include <string>
 #include <functional>
-#include <memory>
-#include <cstdarg>
 
 namespace tvheadend
 {
@@ -58,11 +56,7 @@ namespace tvheadend
        * Returns the singleton instance
        * @return
        */
-      static Logger &GetInstance()
-      {
-        static Logger instance;
-        return instance;
-      }
+      static Logger &GetInstance();
 
       /**
        * Logs the specified message using the specified log level
@@ -70,49 +64,24 @@ namespace tvheadend
        * @param message the log message
        * @param ... parameters for the log message
        */
-      static void Log(LogLevel level, const std::string &message, ...)
-      {
-        auto &logger = GetInstance();
-
-        char buffer[MESSAGE_BUFFER_SIZE];
-        std::string logMessage = message;
-        std::string prefix = logger.m_prefix;
-
-        // Prepend the prefix when set
-        if (!prefix.empty())
-          logMessage = prefix + " - " + message;
-
-        va_list arguments;
-        va_start(arguments, message);
-        vsprintf(buffer, logMessage.c_str(), arguments);
-        va_end(arguments);
-
-        logger.m_implementation(level, buffer);
-      }
+      static void Log(LogLevel level, const std::string &message, ...);
 
       /**
        * Configures the logger to use the specified implementation
-       * @þaram implementation lambda
+       * @param implementation lambda
        */
-      void SetImplementation(LoggerImplementation implementation)
-      {
-        m_implementation = implementation;
-      }
+      void SetImplementation(LoggerImplementation implementation);
 
       /**
        * Sets the prefix to use in log messages
        * @param prefix
        */
-      void SetPrefix(const std::string &prefix)
-      {
-        m_prefix = prefix;
-      }
+      void SetPrefix(const std::string &prefix);
 
     private:
       static const unsigned int MESSAGE_BUFFER_SIZE = 16384;
 
-      Logger()
-      { };
+      Logger();
 
       /**
        * The logger implementation

-- 
kodi-pvr-hts packaging



More information about the pkg-multimedia-commits mailing list