Broke circular dependency between threads and utils.
authorJim Carroll <thecarrolls@jiminger.com>
Wed, 21 Sep 2011 02:06:13 +0000 (22:06 -0400)
committerJim Carroll <thecarrolls@jiminger.com>
Sat, 21 Apr 2012 11:54:10 +0000 (07:54 -0400)
This took the following steps:
1) Created a "commons" library with a logger interface ILogger
2) Made CThread dependent on the ILogger interface.
3) Created an ILogger implementation as part of CLog in utils.
4) Set the logger implementation for CThread at the xbmc app level.
5) Project changes for removing circ. deps.

15 files changed:
Makefile.in
project/VS2010Express/XBMC.vcxproj
project/VS2010Express/XBMC.vcxproj.filters
xbmc/Makefile.in
xbmc/XbmcContext.cpp [new file with mode: 0644]
xbmc/XbmcContext.h [new file with mode: 0644]
xbmc/commons/Makefile [new file with mode: 0644]
xbmc/commons/ilog.cpp [new file with mode: 0644]
xbmc/commons/ilog.h [new file with mode: 0644]
xbmc/threads/Thread.cpp
xbmc/threads/Thread.h
xbmc/threads/platform/pthreads/ThreadImpl.cpp
xbmc/threads/platform/win/ThreadImpl.cpp
xbmc/utils/log.h
xbmc/xbmc.cpp

index 354ec0b..e0e571a 100755 (executable)
@@ -30,6 +30,7 @@ DIRECTORY_ARCHIVES=$(DVDPLAYER_ARCHIVES) \
                    lib/xbmc-dll-symbols/dll-symbols.a \
                    xbmc/addons/addons.a \
                    xbmc/cdrip/cdrip.a \
+                   xbmc/commons/commons.a \
                    xbmc/cores/AudioRenderers/audiorenderers.a \
                    xbmc/cores/DllLoader/dllloader.a \
                    xbmc/cores/DllLoader/exports/exports.a \
@@ -306,7 +307,6 @@ xcode_depends: \
        lib/libXDAAP/libxdaap.a \
        lib/SlingboxLib/SlingboxLib.a
 
-
 OBJSXBMC =$(DIRECTORY_ARCHIVES)
 OBJSXBMC+=lib/libapetag/.libs/libapetag.a
 
@@ -325,7 +325,8 @@ OBJSXBMC:=$(filter-out $(DYNOBJSXBMC), $(OBJSXBMC))
 
 LIBS += @PYTHON_LDFLAGS@
 
-xbmc.bin: $(OBJSXBMC) $(DYNOBJSXBMC)
+xbmc.bin: $(OBJSXBMC) $(DYNOBJSXBMC) $(NWAOBJSXBMC)
+
 ifeq ($(findstring osx,@ARCH@), osx)
        $(SILENT_LD) $(CXX) $(LDFLAGS) -o xbmc.bin -Wl,-all_load,-ObjC $(DYNOBJSXBMC) $(OBJSXBMC) $(LIBS) -rdynamic
 else
index 342812d..b45ffd5 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="Debug (DirectX)|Win32">
     <ClCompile Include="..\..\xbmc\Autorun.cpp" />
     <ClCompile Include="..\..\xbmc\AutoSwitch.cpp" />
     <ClCompile Include="..\..\xbmc\BackgroundInfoLoader.cpp" />
+    <ClCompile Include="..\..\xbmc\commons\ilog.cpp" />
     <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Video\CrystalHD.cpp" />
     <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDInputStreams\DVDInputStreamBluray.cpp" />
     <ClCompile Include="..\..\xbmc\cores\paplayer\BXAcodec.cpp" />
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (OpenGL)|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Template|Win32'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="..\..\xbmc\XbmcContext.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\lib\DllAvFilter.h" />
     <ClInclude Include="..\..\xbmc\Autorun.h" />
     <ClInclude Include="..\..\xbmc\AutoSwitch.h" />
     <ClInclude Include="..\..\xbmc\BackgroundInfoLoader.h" />
+    <ClInclude Include="..\..\xbmc\commons\ilog.h" />
     <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Video\CrystalHD.h" />
     <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDInputStreams\DVDInputStreamBluray.h" />
     <ClInclude Include="..\..\xbmc\cores\paplayer\BXAcodec.h" />
     <ClInclude Include="..\..\xbmc\win32\pch.h" />
     <ClInclude Include="..\..\xbmc\win32\PlatformDefs.h" />
     <ClInclude Include="..\..\xbmc\XBDateTime.h" />
+    <ClInclude Include="..\..\xbmc\XbmcContext.h" />
     <CustomBuild Include="..\..\xbmc\win32\PlatformInclude.h">
       <Command Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">update_git_rev.bat</Command>
       <Outputs Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">..\..\xbmc\win32\git_rev.h;%(Outputs)</Outputs>
index 0ba9a08..9ca84ba 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup>
     <Filter Include="win32">
     <Filter Include="network\httprequesthandler">
       <UniqueIdentifier>{9029e610-aa5a-4414-9e96-1d69f03b3bd8}</UniqueIdentifier>
     </Filter>
+    <Filter Include="commons">
+      <UniqueIdentifier>{d72cae28-bfc8-4a16-befc-dab99a62407b}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\xbmc\win32\pch.cpp">
     <ClCompile Include="..\..\xbmc\MediaSource.cpp">
       <Filter>utils</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\xbmc\XbmcContext.cpp" />
+    <ClCompile Include="..\..\xbmc\commons\ilog.cpp">
+      <Filter>commons</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\xbmc\win32\pch.h">
     <ClInclude Include="..\..\xbmc\win32\WindowHelper.h">
       <Filter>win32</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\xbmc\win32\WINFileSMB.h">
+      <Filter>win32</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\xbmc\win32\WINSMBDirectory.h">
+      <Filter>win32</Filter>
+    </ClInclude>
     <ClInclude Include="..\..\xbmc\cores\DummyVideoPlayer.h">
       <Filter>cores</Filter>
     </ClInclude>
       <Filter>filesystem</Filter>
     </ClInclude>
     <ClInclude Include="..\..\xbmc\cores\paplayer\PCMCodec.h">
-      <Filter>cores\paplayer</Filter>
+      <Filter>cores\paplayer</Filter>=
+    </ClInclude>
+    <ClInclude Include="..\..\xbmc\XbmcContext.h" />
+    <ClInclude Include="..\..\xbmc\commons\ilog.h">
+      <Filter>commons</Filter>
     </ClInclude>
     <ClInclude Include="..\..\xbmc\filesystem\MemBufferCache.h">
       <Filter>filesystem</Filter>
index e33a30a..60501e8 100644 (file)
@@ -33,6 +33,7 @@ SRCS=Application.cpp \
      XBApplicationEx.cpp \
      XBDateTime.cpp \
      xbmc.cpp \
+     XbmcContext.cpp \
 
 LIB=xbmc.a
 
diff --git a/xbmc/XbmcContext.cpp b/xbmc/XbmcContext.cpp
new file mode 100644 (file)
index 0000000..72b14ae
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ *      Copyright (C) 2005-2011 Team XBMC
+ *      http://www.xbmc.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, 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 "XbmcContext.h"
+
+#include "threads/Thread.h"
+#include "utils/log.h"
+
+namespace XBMC
+{
+
+  class ContextOpaque
+  {
+  public:
+    XbmcCommons::ILogger* loggerImpl;
+
+    ContextOpaque() : loggerImpl(NULL) {}
+  };
+
+  Context::Context()
+  {
+    impl = new ContextOpaque;
+
+    // instantiate
+    impl->loggerImpl = new XbmcUtils::LogImplementation;
+
+    // set
+    CThread::SetLogger(impl->loggerImpl);
+  }
+
+  Context::~Context()
+  {
+    // cleanup
+    delete impl->loggerImpl;
+
+    delete impl;
+  }
+}
+
diff --git a/xbmc/XbmcContext.h b/xbmc/XbmcContext.h
new file mode 100644 (file)
index 0000000..8684b82
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *      Copyright (C) 2005-2011 Team XBMC
+ *      http://www.xbmc.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, 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
+ *
+ */
+
+#pragma once
+
+namespace XBMC
+{
+  class ContextOpaque;
+
+  /**
+   * This class sets up a few instances and services. Currently it only
+   *  provides a logger to the CThread functionality. If it never does
+   *  more than this it can be removed.
+   */
+  class Context
+  {
+    ContextOpaque* impl;
+  public:
+    Context();
+    virtual ~Context();
+  };
+}
+
+
+
diff --git a/xbmc/commons/Makefile b/xbmc/commons/Makefile
new file mode 100644 (file)
index 0000000..97fdc2f
--- /dev/null
@@ -0,0 +1,8 @@
+SRCS= \
+       ilog.cpp
+
+
+LIB=commons.a
+
+include ../../Makefile.include
+-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(patsubst %.S,,$(SRCS))))
diff --git a/xbmc/commons/ilog.cpp b/xbmc/commons/ilog.cpp
new file mode 100644 (file)
index 0000000..ca70191
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *      Copyright (C) 2005-2011 Team XBMC
+ *      http://www.xbmc.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, 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 "commons/ilog.h"
+#include "utils/StdString.h"
+
+namespace XbmcCommons
+{
+  void ILogger::Log(int loglevel, const char *format, ... )
+  {
+    CStdString strData;
+
+    strData.reserve(16384);
+    va_list va;
+    va_start(va, format);
+    strData.FormatV(format,va);
+    va_end(va);
+
+    log(loglevel, strData);
+  }
+}
diff --git a/xbmc/commons/ilog.h b/xbmc/commons/ilog.h
new file mode 100644 (file)
index 0000000..9f61d8d
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ *      Copyright (C) 2005-2011 Team XBMC
+ *      http://www.xbmc.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, 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
+ *
+ */
+
+#pragma once
+
+#include <stdio.h>
+
+#define LOG_LEVEL_NONE         -1 // nothing at all is logged
+#define LOG_LEVEL_NORMAL        0 // shows notice, error, severe and fatal
+#define LOG_LEVEL_DEBUG         1 // shows all
+#define LOG_LEVEL_DEBUG_FREEMEM 2 // shows all + shows freemem on screen
+#define LOG_LEVEL_DEBUG_SAMBA   3 // shows all + freemem on screen + samba debugging
+#define LOG_LEVEL_MAX           LOG_LEVEL_DEBUG_SAMBA
+
+// ones we use in the code
+#define LOGDEBUG   0
+#define LOGINFO    1
+#define LOGNOTICE  2
+#define LOGWARNING 3
+#define LOGERROR   4
+#define LOGSEVERE  5
+#define LOGFATAL   6
+#define LOGNONE    7
+
+#ifdef __GNUC__
+#define ATTRIB_LOG_FORMAT __attribute__((format(printf,3,4)))
+#else
+#define ATTRIB_LOG_FORMAT
+#endif
+
+namespace XbmcCommons
+{
+  class ILogger
+  {
+  public:
+    void Log(int loglevel, const char *format, ... ) ATTRIB_LOG_FORMAT;
+
+    virtual void log(int loglevel, const char* message) = 0;
+  };
+}
+
+#undef ATTRIB_LOG_FORMAT
index becc594..f6b9bf8 100644 (file)
 #include "threads/SystemClock.h"
 #include "Thread.h"
 #include "utils/log.h"
-#include "utils/TimeUtils.h"
 #include "threads/ThreadLocal.h"
+#include "threads/SingleLock.h"
 
 #define __STDC_FORMAT_MACROS
 #include <inttypes.h>
 
 static XbmcThreads::ThreadLocal<CThread> currentThread;
 
+XbmcCommons::ILogger* CThread::logger = NULL;
+
 #include "threads/platform/ThreadImpl.cpp"
 
 //////////////////////////////////////////////////////////////////////
@@ -87,7 +89,7 @@ THREADFUNC CThread::staticThread(void* data)
   bool autodelete;
 
   if (!pThread) {
-    CLog::Log(LOGERROR,"%s, sanity failed. thread is NULL.",__FUNCTION__);
+    if(logger) logger->Log(LOGERROR,"%s, sanity failed. thread is NULL.",__FUNCTION__);
     return 1;
   }
 
@@ -97,7 +99,7 @@ THREADFUNC CThread::staticThread(void* data)
 
   pThread->SetThreadInfo();
 
-  CLog::Log(LOGNOTICE,"Thread %s start, auto delete: %s", name.c_str(), (autodelete ? "true" : "false"));
+  if(logger) logger->Log(LOGNOTICE,"Thread %s start, auto delete: %s", name.c_str(), (autodelete ? "true" : "false"));
 
   currentThread.set(pThread);
   pThread->m_StartEvent.Set();
@@ -117,12 +119,12 @@ THREADFUNC CThread::staticThread(void* data)
 
   if (autodelete)
   {
-    CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating (autodelete)", name.c_str(), (uint64_t)id);
+    if(logger) logger->Log(LOGDEBUG,"Thread %s %"PRIu64" terminating (autodelete)", name.c_str(), (uint64_t)id);
     delete pThread;
     pThread = NULL;
   }
   else
-    CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating", name.c_str(), (uint64_t)id);
+    if(logger) logger->Log(LOGDEBUG,"Thread %s %"PRIu64" terminating", name.c_str(), (uint64_t)id);
 
   return 0;
 }
index bebd9ee..e513606 100644 (file)
@@ -30,6 +30,7 @@
 #include "Event.h"
 #include "threads/ThreadImpl.h"
 #include "threads/ThreadLocal.h"
+#include "commons/ilog.h"
 
 class IRunnable
 {
@@ -41,10 +42,16 @@ public:
 // minimum as mandated by XTL
 #define THREAD_MINSTACKSIZE 0x10000
 
+namespace XbmcThreads { class ThreadSettings; }
+
 class CThread
 {
-public:
+  static XbmcCommons::ILogger* logger;
+
+protected:
   CThread(const char* ThreadName);
+
+public:
   CThread(IRunnable* pRunnable, const char* ThreadName);
   virtual ~CThread();
   void Create(bool bAutoDelete = false, unsigned stacksize = 0);
@@ -68,6 +75,7 @@ public:
   static ThreadIdentifier GetCurrentThreadId();
   static CThread* GetCurrentThread();
   static int64_t GetCurrentThreadUsage();
+  static inline void SetLogger(XbmcCommons::ILogger* logger_) { CThread::logger = logger_; }
 protected:
   virtual void OnStartup(){};
   virtual void OnExit(){};
@@ -87,7 +95,7 @@ protected:
   {
     XbmcThreads::CEventGroup group(&event, &m_StopEvent, NULL);
     CEvent* result = group.wait(timeoutMillis);
-    return  result == &event ? WAIT_SIGNALED : 
+    return  result == &event ? WAIT_SIGNALED :
       (result == NULL ? WAIT_TIMEDOUT : WAIT_INTERRUPTED);
   }
 
@@ -95,7 +103,7 @@ protected:
   {
     XbmcThreads::CEventGroup group(&event, &m_StopEvent, NULL);
     CEvent* result = group.wait();
-    return  result == &event ? WAIT_SIGNALED : 
+    return  result == &event ? WAIT_SIGNALED :
       (result == NULL ? WAIT_TIMEDOUT : WAIT_INTERRUPTED);
   }
 
index 58b602c..6807669 100644 (file)
@@ -28,7 +28,7 @@ void CThread::Create(bool bAutoDelete, unsigned stacksize)
 {
   if (m_ThreadId != 0)
   {
-    CLog::Log(LOGERROR, "%s - fatal error creating thread- old thread id not null", __FUNCTION__);
+    if (logger) logger->Log(LOGERROR, "%s - fatal error creating thread- old thread id not null", __FUNCTION__);
     exit(1);
   }
   m_iLastTime = XbmcThreads::SystemClockMillis() * 10000;
@@ -47,7 +47,7 @@ void CThread::Create(bool bAutoDelete, unsigned stacksize)
   pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
   if (pthread_create(&m_ThreadId, &attr, (void*(*)(void*))staticThread, this) != 0)
   {
-    CLog::Log(LOGNOTICE, "%s - fatal error creating thread",__FUNCTION__);
+    if (logger) logger->Log(LOGNOTICE, "%s - fatal error creating thread",__FUNCTION__);
   }
   pthread_attr_destroy(&attr);
 }
@@ -64,7 +64,7 @@ void CThread::SetThreadInfo()
   // start thread with nice level of appication
   int appNice = getpriority(PRIO_PROCESS, getpid());
   if (setpriority(PRIO_PROCESS, m_ThreadOpaque.LwpId, appNice) != 0)
-    CLog::Log(LOGERROR, "%s: error %s", __FUNCTION__, strerror(errno));
+    if (logger) logger->Log(LOGERROR, "%s: error %s", __FUNCTION__, strerror(errno));
 }
 
 ThreadIdentifier CThread::GetCurrentThreadId()
@@ -138,7 +138,7 @@ bool CThread::SetPriority(const int iPriority)
     if (setpriority(PRIO_PROCESS, m_ThreadOpaque.LwpId, prio) == 0)
       bReturn = true;
     else
-      CLog::Log(LOGERROR, "%s: error %s", __FUNCTION__, strerror(errno));
+      if (logger) logger->Log(LOGERROR, "%s: error %s", __FUNCTION__, strerror(errno));
   }
 
   return bReturn;
index 6650ee6..272e3ba 100644 (file)
@@ -26,7 +26,7 @@ void CThread::Create(bool bAutoDelete, unsigned stacksize)
 {
   if (m_ThreadId != 0)
   {
-    CLog::Log(LOGERROR, "%s - fatal error creating thread- old thread id not null", __FUNCTION__);
+    if (logger) logger->Log(LOGERROR, "%s - fatal error creating thread- old thread id not null", __FUNCTION__);
     exit(1);
   }
   m_iLastTime = XbmcThreads::SystemClockMillis() * 10000;
@@ -41,7 +41,7 @@ void CThread::Create(bool bAutoDelete, unsigned stacksize)
   m_ThreadOpaque.handle = CreateThread(NULL,stacksize, (LPTHREAD_START_ROUTINE)&staticThread, this, 0, &m_ThreadId);
   if (m_ThreadOpaque.handle == NULL)
   {
-    CLog::Log(LOGERROR, "%s - fatal error creating thread", __FUNCTION__);
+    if (logger) logger->Log(LOGERROR, "%s - fatal error creating thread", __FUNCTION__);
   }
 }
 
index 673882e..14e26f4 100644 (file)
 #include <stdio.h>
 #include <string>
 
+#include "commons/ilog.h"
 #include "threads/CriticalSection.h"
 #include "utils/GlobalsHandling.h"
 
-#define LOG_LEVEL_NONE         -1 // nothing at all is logged
-#define LOG_LEVEL_NORMAL        0 // shows notice, error, severe and fatal
-#define LOG_LEVEL_DEBUG         1 // shows all
-#define LOG_LEVEL_DEBUG_FREEMEM 2 // shows all + shows freemem on screen
-#define LOG_LEVEL_DEBUG_SAMBA   3 // shows all + freemem on screen + samba debugging
-#define LOG_LEVEL_MAX           LOG_LEVEL_DEBUG_SAMBA
-
-// ones we use in the code
-#define LOGDEBUG   0
-#define LOGINFO    1
-#define LOGNOTICE  2
-#define LOGWARNING 3
-#define LOGERROR   4
-#define LOGSEVERE  5
-#define LOGFATAL   6
-#define LOGNONE    7
-
 #ifdef __GNUC__
 #define ATTRIB_LOG_FORMAT __attribute__((format(printf,2,3)))
 #else
@@ -78,4 +62,15 @@ private:
   static void OutputDebugString(const std::string& line);
 };
 
+#undef ATTRIB_LOG_FORMAT
+
+namespace XbmcUtils
+{
+  class LogImplementation : public XbmcCommons::ILogger
+  {
+  public:
+    inline virtual void log(int logLevel, const char* message) { CLog::Log(logLevel,"%s",message); }
+  };
+}
+
 XBMC_GLOBAL_REF(CLog::CLogGlobals,g_log_globals);
index b6d3bac..90013bc 100644 (file)
 #ifdef HAS_LIRC
 #include "input/linux/LIRC.h"
 #endif
+#include "XbmcContext.h"
 
 int main(int argc, char* argv[])
 {
+  // set up some xbmc specific relationships
+  XBMC::Context context;
+
   int status = -1;
   //this can't be set from CAdvancedSettings::Initialize() because it will overwrite
   //the loglevel set with the --debug flag