Permalink
Browse files

WIP

  • Loading branch information...
1 parent 0c80911 commit eaa3d4d3521efe5e1e1f74c5992c3c7668a2c3b5 Jim Carroll committed Nov 4, 2015
@@ -481,15 +481,6 @@ bool CApplication::Create()
CopyUserDataIfNeeded("special://masterprofile/", "favourites.xml");
CopyUserDataIfNeeded("special://masterprofile/", "Lircmap.xml");
- if (!CLog::Init(CSpecialProtocol::TranslatePath(g_advancedSettings.m_logFolder).c_str()))
- {
- std::string lcAppName = CCompileInfo::GetAppName();
- StringUtils::ToLower(lcAppName);
- fprintf(stderr,"Could not init logging classes. Permission errors on ~/.%s (%s)\n", lcAppName.c_str(),
- CSpecialProtocol::TranslatePath(g_advancedSettings.m_logFolder).c_str());
- return false;
- }
-
// Init our DllLoaders emu env
init_emu_environ();
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://xbmc.org
+ * Copyright (C) 2005-2015 Team XBMC
+ * 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
@@ -13,17 +13,22 @@
* 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, see
+ * along with Kodi; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
-#include "Exception.h"
+/**
+ * The constructor of this class initializes the Kodi specific directories
+ * which will be platform specific. The various implementations are in the
+ * platform subdirectory.
+ */
-namespace XbmcCommons
+namespace KODI
{
- ILogger* Exception::logger = NULL;
-
- Exception::~Exception() {}
+ class DirectoryInitializer {
+ public:
+ DirectoryInitializer();
+ ~DirectoryInitializer();
+ };
}
-
View
@@ -10,6 +10,7 @@ SRCS=Application.cpp \
CueDocument.cpp \
DatabaseManager.cpp \
DbUrl.cpp \
+ platform/linux/DirectoryInit.cpp \
DynamicDll.cpp \
FileItem.cpp \
FileItemListModification.cpp \
View
@@ -24,37 +24,42 @@
#include "commons/Exception.h"
#include "utils/log.h"
-namespace XBMC
-{
+// Log implementation
+#if defined(TARGET_POSIX)
+#include "utils/posix/PosixInterfaceForCLog.h"
+#elif defined(TARGET_WINDOWS)
+#include "utils/win32/Win32InterfaceForCLog.h"
+#endif
- class ContextOpaque
- {
- public:
- XbmcCommons::ILogger* loggerImpl;
+#include "settings/AdvancedSettings.h"
+#include "filesystem/SpecialProtocol.h"
+#include "CompileInfo.h"
- ContextOpaque() : loggerImpl(NULL) {}
- };
+using namespace di;
+namespace XBMC
+{
Context::Context()
{
- impl = new ContextOpaque;
+ // advanced setting should be injected here eventually also
+ printf("log folder: %s", g_advancedSettings.m_logFolder.c_str());
+ std::string logFilename = CSpecialProtocol::TranslatePath(g_advancedSettings.m_logFolder) + CCompileInfo::GetAppName();
+
+ // Add an XbmcCommons::ILogger
+#if defined(TARGET_POSIX)
+ ctx.has(Instance<CPosixInterfaceForCLog>(), Constant<std::string>(logFilename)).isAlso(Instance<XbmcCommons::ILogger>());
+#elif defined(TARGET_WINDOWS)
+ ctx.has(Instance<CWin32InterfaceForCLog>(), Constant<std::string>(logFilename)).isAlso(Instance<XbmcCommons::ILogger>());
+#endif
- // instantiate
- impl->loggerImpl = new XbmcUtils::LogImplementation;
+ ctx.has(Instance<CLog::DiHelper>(), Instance<XbmcCommons::ILogger>());
- // set
- XbmcCommons::Exception::SetLogger(impl->loggerImpl);
- CThread::SetLogger(impl->loggerImpl);
+ ctx.start();
}
Context::~Context()
{
- // cleanup
- XbmcCommons::Exception::SetLogger(NULL);
- CThread::SetLogger(NULL);
- delete impl->loggerImpl;
-
- delete impl;
+ ctx.stop();
}
}
View
@@ -20,18 +20,18 @@
#pragma once
+#include "commons/di.h"
+
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;
+ di::Context ctx;
public:
Context();
virtual ~Context();
@@ -26,7 +26,6 @@
// a header.
#include "utils/StringUtils.h"
//---------------------------------------------------------
-#include "ilog.h"
#include <stdarg.h>
#ifdef __GNUC__
@@ -61,7 +60,6 @@ namespace XbmcCommons
std::string message;
protected:
- static ILogger* logger;
inline Exception(const char* classname_) : classname(classname_) { }
inline Exception(const char* classname_, const char* message_) : classname(classname_), message(message_) { }
@@ -89,17 +87,11 @@ namespace XbmcCommons
inline void setClassname(const char* cn) { classname = cn; }
public:
- virtual ~Exception();
+ virtual inline ~Exception() {}
- inline virtual void LogThrowMessage(const char* prefix = NULL) const
- {
- if (logger)
- logger->Log(LOGERROR,"EXCEPTION Thrown (%s) : %s", classname.c_str(), message.c_str());
- }
+ inline const char* GetClassname() const { return classname.c_str(); }
inline virtual const char* GetMessage() const { return message.c_str(); }
-
- inline static void SetLogger(ILogger* exceptionLogger) { logger = exceptionLogger; }
};
/**
@@ -1,7 +1,6 @@
SRCS= \
- Exception.cpp \
- ilog.cpp \
- di.cpp
+ di.cpp \
+ log.cpp
LIB=commons.a
@@ -32,8 +32,6 @@ namespace internal
#ifdef DI__DEPENDENCY_INJECTION_DEBUG
std::cout << "requirement:" << toString() << " is satisfied by " << dep->toString() << std::endl;
#endif
- std::vector<BeanBase*> satisfiedBy;
- BeanBase* dep = satisfiedBy.front();
(((T*)instance->getConcrete())->*(setter)) (parameter.findIsAlso(context));
}
View
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://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, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "commons/ilog.h"
-#include "utils/StringUtils.h"
-
-namespace XbmcCommons
-{
- void ILogger::Log(int loglevel, const char *format, ... )
- {
- std::string strData;
-
- strData.reserve(16384);
- va_list va;
- va_start(va, format);
- strData = StringUtils::FormatV(format,va);
- va_end(va);
-
- log(loglevel, strData.c_str());
- }
-}
View
@@ -20,7 +20,7 @@
#pragma once
-#include <stdio.h>
+#include <string>
#define LOG_LEVEL_NONE -1 // nothing at all is logged
#define LOG_LEVEL_NORMAL 0 // shows notice, error, severe and fatal
@@ -54,17 +54,15 @@
#define LOGCEC (1 << (LOGMASKBIT + 9))
#define LOGVIDEO (1 << (LOGMASKBIT + 10))
-#include "utils/params_check_macros.h"
-
namespace XbmcCommons
{
class ILogger
{
public:
virtual ~ILogger() {}
- void Log(int loglevel, PRINTF_FORMAT_STRING const char *format, ...) PARAM3_PRINTF_FORMAT;
- virtual void log(int loglevel, IN_STRING const char* message) = 0;
+ virtual void Log(const std::string& message) = 0;
+ virtual void PrintDebugString(const std::string& message) = 0;
};
}
Oops, something went wrong. Retry.

0 comments on commit eaa3d4d

Please sign in to comment.