Commit 58b933f8 authored by jacobgladish's avatar jacobgladish

Added AllJoyn logger callback.

There seems to be a bug in alljoyn core that prevents us from registering the callback. I
have the callback implemented, but the actual registration is commented out for now until
we resolve.
parent 03d8eb2e
#include "Bridge.h"
#include "Common/Log.h"
#include "Bridge/BridgeDevice.h"
#include <qcc/Debug.h>
#include <alljoyn/Init.h>
namespace
......@@ -18,6 +18,39 @@ namespace
{
return dev.get();
}
void alljoynLogger(DbgMsgType type, char const* module, char const* msg, void* /*ctx*/)
{
common::Logger::Level level = common::Logger::DSB_LOGLEVEL_INFO;
switch (type)
{
case DBG_LOCAL_ERROR:
case DBG_REMOTE_ERROR:
level = common::Logger::DSB_LOGLEVEL_ERROR;
break;
case DBG_HIGH_LEVEL:
level = common::Logger::DSB_LOGLEVEL_WARN;
break;
case DBG_GEN_MESSAGE:
level = common::Logger::DSB_LOGLEVEL_INFO;
break;
case DBG_API_TRACE:
case DBG_REMOTE_DATA:
case DBG_LOCAL_DATA:
level = common::Logger::DSB_LOGLEVEL_DEBUG;
}
common::Logger::Write("alljoyn", level, NULL, 0, "[%s] %s", module, msg);
}
void RegisterAllJoynLogger()
{
static bool alljoynLoggerRegistered = false;
if (!alljoynLoggerRegistered)
{
alljoynLoggerRegistered = true;
QCC_RegisterOutputCallback(alljoynLogger, NULL);
}
}
}
bridge::DeviceSystemBridge::DeviceSystemBridge(shared_ptr<IAdapter> const& adapter)
......@@ -26,6 +59,8 @@ bridge::DeviceSystemBridge::DeviceSystemBridge(shared_ptr<IAdapter> const& adapt
, m_adapterSignalListener(new AdapterSignalListener(*this))
, m_configManager(*this, *adapter)
{
// TODO: bug in alljoyn prevents registering logger.
// RegisterAllJoynLogger();
}
bridge::DeviceSystemBridge::~DeviceSystemBridge()
......@@ -43,12 +78,14 @@ bridge::DeviceSystemBridge::Initialize()
DSBLOG_DEBUG(__FUNCTION__);
if (!m_alljoynInitialized)
{
DSBLOG_INFO("initialize AllJoyn");
st = AllJoynInit();
if (st != ER_OK)
{
DSBLOG_WARN("Failed to initialize AllJoyn: %s", QCC_StatusText(st));
DSBLOG_WARN("initialize AllJoyn failed: %s", QCC_StatusText(st));
goto Leave;
}
m_alljoynInitialized = true;
}
......@@ -70,34 +107,46 @@ bridge::DeviceSystemBridge::InitializeInternal()
{
QStatus st = ER_OK;
DSBLOG_INFO("initialize configuration manager");
st = m_configManager.Initialize();
if (st != ER_OK)
{
DSBLOG_WARN("initialize configuration manager failed: %s", QCC_StatusText(st));
goto Leave;
}
DSBLOG_INFO("initialize adapter");
st = InitializeAdapter();
if (st != ER_OK)
{
DSBLOG_WARN("Failed to intialize adapter: %s", QCC_StatusText(st));
DSBLOG_WARN("initialize adapter failed: %s", QCC_StatusText(st));
goto Leave;
}
DSBLOG_INFO("connect to AllJoyn router");
st = m_configManager.ConnectToAllJoyn();
if (st != ER_OK)
{
DSBLOG_INFO("connect to AllJoyn router failed: %s", QCC_StatusText(st));
goto Leave;
}
DSBLOG_INFO("initialize devices");
st = InitializeDevices();
if (st != ER_OK)
{
DSBLOG_WARN("Failed to initialize devices: %s", QCC_StatusText(st));
DSBLOG_WARN("initialize devices failed: %s", QCC_StatusText(st));
goto Leave;
}
DSBLOG_INFO("registering signal handlers");
st = RegisterAdapterSignalHandlers(true);
if (st != ER_OK)
{
DSBLOG_WARN("Failed to register adapter signal handlers: %s", QCC_StatusText(st));
DSBLOG_WARN("register signal handlers failed: %s", QCC_StatusText(st));
goto Leave;
}
......
......@@ -38,12 +38,12 @@ namespace common
#define DSBLOG_WITH_LEVEL(LEVEL, FORMAT, ...) \
do { if (common::Logger::IsLevelEnabled(__dsb_logger_module_name__, LEVEL)) { \
common::Logger::Write(__dsb_logger_module_name__, LEVEL, __FILE__, __LINE__ - 2, FORMAT, ##__VA_ARGS__); \
common::Logger::Write(__dsb_logger_module_name__, LEVEL, __FILE__, __LINE__, FORMAT, ##__VA_ARGS__); \
} } while (0)
#define DSBLOG(LEVEL, NAME, FORMAT, ...) \
do { if (common::Logger::IsLevelEnabled(NAME, common::Logger::LEVEL)) { \
common::Logger::Write(NAME, common::Logger::LEVEL, __FILE__, __LINE__ - 2, FORMAT, ##__VA_ARGS__); \
common::Logger::Write(NAME, common::Logger::LEVEL, __FILE__, __LINE__, FORMAT, ##__VA_ARGS__); \
} } while (0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment