Skip to content

Commit

Permalink
Merge pull request #14 from GENIVI/ALSARA_new_logging_architecture
Browse files Browse the repository at this point in the history
ALSARA: convert logging
  • Loading branch information
Martin Koch authored Feb 24, 2020
2 parents 6244e64 + 4b98a2b commit b5090c9
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 78 deletions.
17 changes: 1 addition & 16 deletions PluginRoutingAdapterALSA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@ FIND_PACKAGE(PkgConfig)
PROJECT(PluginRoutingAdapterALSA)

FIND_PACKAGE(AudioManager REQUIRED > 7.3.0)
FIND_PACKAGE(AudioManagerUtilities REQUIRED > 7.3.0)

IF (WITH_DLT)
pkg_check_modules(DLT_REQUIRED automotive-dlt>=2.2.0)
add_definitions(${DLT_CFLAGS_OTHER})
include_directories(${DLT_INCLUDE_DIRS})
link_directories(${DLT_LIBRARY_DIRS})
ENDIF(WITH_DLT)
FIND_PACKAGE(AudioManagerUtilities REQUIRED > 7.7.0)

OPTION (WITH_DOCUMENTATION
"build plugins with documentation" OFF )
Expand Down Expand Up @@ -68,14 +61,6 @@ INCLUDE_DIRECTORIES(
${INCLUDE_FOLDER}
)

IF(WITH_DLT)
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES}
${DLT_INCLUDE_DIRS})
SET(AM_LINK_LIBS
${AM_LINK_LIBS}
${DLT_LIBRARIES})
ENDIF(WITH_DLT)

add_definitions(-DROUTING_ADAPTER_ALSA_DEFAULT_CONF_ROOT="${CONF_ROOT}")

##build flags set(CPACK_RPM_COMPONENT_INSTALL ON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,48 +26,48 @@
* For further information see http://www.genivi.org/.
******************************************************************************/

#ifndef CAMDLTLOGGING_H_
#define CAMDLTLOGGING_H_
#ifndef CAMRAALSALOGGING_H_
#define CAMRAALSALOGGING_H_

#include "CAmDltWrapper.h"
#include "CAmLogWrapper.h"

#define CONTEXT "AMRA"

namespace am
{

/**
* \brief DLT logging on AMRA Context
* \brief Short-hand notations for a logging context dedicated to the ALSA Routing-Adapter
*
* This class is a Singleton which allows Plugin Routing Adapter ALSA to DLT log towards its own Context
* This class is implemented as Singleton
*/
class CAmDLTLogging
class CAmRaAlsaLogging
{
public:
/**
* Allows to retrieve the Singleton
*/
static CAmDLTLogging *Instance();
static CAmRaAlsaLogging *Instance();
/**
* dtor
*/
virtual ~CAmDLTLogging();
virtual ~CAmRaAlsaLogging();

/**
* returns a pointer to the DltContext. Such Context is then used when implementing
* the variadic template logging functions used throughout the plugin
* provide access to logging context
*/
DltContext *getContextPointer();
inline static IAmLogContext &getContext()
{
return Instance()->mContext;
}

private:
/**
* private ctor being a singleton
*/
CAmDLTLogging();

private:
DltContext mContext;
static CAmDLTLogging *mCAmDLTLogging;
CAmRaAlsaLogging();

IAmLogContext &mContext;
static CAmRaAlsaLogging *mpLogging;
};

/**
Expand All @@ -78,12 +78,7 @@ class CAmDLTLogging
template<typename T, typename... TArgs>
void logAmRaDebug(T value, TArgs... args)
{
CAmDltWrapper* inst(CAmDltWrapper::instance());
if (!inst->init(DLT_LOG_DEBUG, CAmDLTLogging::Instance()->getContextPointer()))
return;
inst->append(value);
inst->append(args...);
inst->send();
CAmRaAlsaLogging::getContext().debug(value, args...);
}

/**
Expand All @@ -94,12 +89,7 @@ void logAmRaDebug(T value, TArgs... args)
template<typename T, typename... TArgs>
void logAmRaInfo(T value, TArgs... args)
{
CAmDltWrapper* inst(CAmDltWrapper::instance());
if (!inst->init(DLT_LOG_INFO, CAmDLTLogging::Instance()->getContextPointer()))
return;
inst->append(value);
inst->append(args...);
inst->send();
CAmRaAlsaLogging::getContext().info(value, args...);
}

/**
Expand All @@ -110,14 +100,8 @@ void logAmRaInfo(T value, TArgs... args)
template<typename T, typename... TArgs>
void logAmRaError(T value, TArgs... args)
{
CAmDltWrapper* inst(CAmDltWrapper::instance());

if (!inst->init(DLT_LOG_ERROR, CAmDLTLogging::Instance()->getContextPointer()))
return;
inst->append(value);
inst->append(args...);
inst->send();
CAmRaAlsaLogging::getContext().error(value, args...);
}

} /* namespace am */
#endif /* CAMDLTLOGGING_H_ */
#endif /* CAMRAALSALOGGING_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,33 @@
* For further information see http://www.genivi.org/.
******************************************************************************/

#include "CAmDLTLogging.h"
#include "CAmRaAlsaLogging.h"


using namespace am;

CAmDLTLogging *CAmDLTLogging::mCAmDLTLogging = NULL;
CAmRaAlsaLogging *CAmRaAlsaLogging::mpLogging = NULL;


#define LOGCONTEXT "ALSA"
#define LOGDESCRIPTION "Logging Context for Routing-Adapter ALSA"

CAmDLTLogging::CAmDLTLogging()
CAmRaAlsaLogging::CAmRaAlsaLogging()
: mContext(CAmLogWrapper::instance()->registerContext(LOGCONTEXT, LOGDESCRIPTION))
{
CAmDltWrapper::instance()->registerContext(mContext, CONTEXT, "Context for RoutingAdapter");
}

CAmDLTLogging *CAmDLTLogging::Instance()
CAmRaAlsaLogging *CAmRaAlsaLogging::Instance()
{
if (mCAmDLTLogging == NULL)
if (mpLogging == NULL)
{
mCAmDLTLogging = new CAmDLTLogging();
mpLogging = new CAmRaAlsaLogging();
}
return mCAmDLTLogging;
}

CAmDLTLogging::~CAmDLTLogging()
{
CAmDltWrapper::instance()->unregisterContext(mContext);
return mpLogging;
}

DltContext *CAmDLTLogging::getContextPointer()
CAmRaAlsaLogging::~CAmRaAlsaLogging()
{
return &mContext;
CAmLogWrapper::instance()->unregisterContext(LOGCONTEXT);
mpLogging = NULL;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "CAmRoutingAdapterALSAdb.h"
#include "CAmRoutingAdapterALSASender.h"

#include "CAmDLTLogging.h"
#include "CAmRaAlsaLogging.h"

using namespace std;
using namespace am;
Expand Down
4 changes: 1 addition & 3 deletions PluginRoutingAdapterALSA/src/CAmRoutingAdapterALSAParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
#include <stdlib.h> // for getenv()
#include <fstream> //for file operations
#include "CAmRoutingAdapterALSAParser.h"
#include "CAmDLTLogging.h"

DLT_DECLARE_CONTEXT (ALSARoutingAdapterParser)
#include "CAmRaAlsaLogging.h"

using namespace std;
using namespace am;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


#include "CAmRoutingAdapterALSAProxyDefault.h"
#include "CAmDLTLogging.h"
#include "CAmRaAlsaLogging.h"
#include <cerrno>

using namespace am;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

#include "TAmPluginTemplate.h"

#include "CAmDLTLogging.h"
#include "CAmRaAlsaLogging.h"

#define DEFAULT_PLUGIN_STREAMING_DIR DEFAULT_PLUGIN_DIR "/streaming"

Expand Down
4 changes: 1 addition & 3 deletions PluginRoutingAdapterALSA/src/CAmRoutingAdapterALSAVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
#include "audiomanagertypes.h"
#include "CAmRoutingAdapterALSAVolume.h"
#include "CAmRoutingAdapterALSASender.h"
#include "CAmDLTLogging.h"

DLT_DECLARE_CONTEXT (CRaALSAVolume)
#include "CAmRaAlsaLogging.h"


using namespace am;
Expand Down
2 changes: 1 addition & 1 deletion PluginRoutingAdapterALSA/src/CAmRoutingAdapterALSAdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <cassert>
#include <algorithm>
#include "CAmRoutingAdapterALSAdb.h"
#include "CAmDLTLogging.h"
#include "CAmRaAlsaLogging.h"

using namespace std;
using namespace am;
Expand Down

0 comments on commit b5090c9

Please sign in to comment.