Skip to content

Commit b5090c9

Browse files
author
Martin Koch
authored
Merge pull request #14 from GENIVI/ALSARA_new_logging_architecture
ALSARA: convert logging
2 parents 6244e64 + 4b98a2b commit b5090c9

9 files changed

Lines changed: 44 additions & 78 deletions

PluginRoutingAdapterALSA/CMakeLists.txt

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,7 @@ FIND_PACKAGE(PkgConfig)
2222
PROJECT(PluginRoutingAdapterALSA)
2323

2424
FIND_PACKAGE(AudioManager REQUIRED > 7.3.0)
25-
FIND_PACKAGE(AudioManagerUtilities REQUIRED > 7.3.0)
26-
27-
IF (WITH_DLT)
28-
pkg_check_modules(DLT_REQUIRED automotive-dlt>=2.2.0)
29-
add_definitions(${DLT_CFLAGS_OTHER})
30-
include_directories(${DLT_INCLUDE_DIRS})
31-
link_directories(${DLT_LIBRARY_DIRS})
32-
ENDIF(WITH_DLT)
25+
FIND_PACKAGE(AudioManagerUtilities REQUIRED > 7.7.0)
3326

3427
OPTION (WITH_DOCUMENTATION
3528
"build plugins with documentation" OFF )
@@ -68,14 +61,6 @@ INCLUDE_DIRECTORIES(
6861
${INCLUDE_FOLDER}
6962
)
7063

71-
IF(WITH_DLT)
72-
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES}
73-
${DLT_INCLUDE_DIRS})
74-
SET(AM_LINK_LIBS
75-
${AM_LINK_LIBS}
76-
${DLT_LIBRARIES})
77-
ENDIF(WITH_DLT)
78-
7964
add_definitions(-DROUTING_ADAPTER_ALSA_DEFAULT_CONF_ROOT="${CONF_ROOT}")
8065

8166
##build flags set(CPACK_RPM_COMPONENT_INSTALL ON)

PluginRoutingAdapterALSA/include/CAmDLTLogging.h renamed to PluginRoutingAdapterALSA/include/CAmRaAlsaLogging.h

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,48 +26,48 @@
2626
* For further information see http://www.genivi.org/.
2727
******************************************************************************/
2828

29-
#ifndef CAMDLTLOGGING_H_
30-
#define CAMDLTLOGGING_H_
29+
#ifndef CAMRAALSALOGGING_H_
30+
#define CAMRAALSALOGGING_H_
3131

32-
#include "CAmDltWrapper.h"
32+
#include "CAmLogWrapper.h"
3333

34-
#define CONTEXT "AMRA"
3534

3635
namespace am
3736
{
3837

3938
/**
40-
* \brief DLT logging on AMRA Context
39+
* \brief Short-hand notations for a logging context dedicated to the ALSA Routing-Adapter
4140
*
42-
* This class is a Singleton which allows Plugin Routing Adapter ALSA to DLT log towards its own Context
41+
* This class is implemented as Singleton
4342
*/
44-
class CAmDLTLogging
43+
class CAmRaAlsaLogging
4544
{
4645
public:
4746
/**
4847
* Allows to retrieve the Singleton
4948
*/
50-
static CAmDLTLogging *Instance();
49+
static CAmRaAlsaLogging *Instance();
5150
/**
5251
* dtor
5352
*/
54-
virtual ~CAmDLTLogging();
53+
virtual ~CAmRaAlsaLogging();
54+
5555
/**
56-
* returns a pointer to the DltContext. Such Context is then used when implementing
57-
* the variadic template logging functions used throughout the plugin
56+
* provide access to logging context
5857
*/
59-
DltContext *getContextPointer();
58+
inline static IAmLogContext &getContext()
59+
{
60+
return Instance()->mContext;
61+
}
6062

6163
private:
6264
/**
6365
* private ctor being a singleton
6466
*/
65-
CAmDLTLogging();
66-
67-
private:
68-
DltContext mContext;
69-
static CAmDLTLogging *mCAmDLTLogging;
67+
CAmRaAlsaLogging();
7068

69+
IAmLogContext &mContext;
70+
static CAmRaAlsaLogging *mpLogging;
7171
};
7272

7373
/**
@@ -78,12 +78,7 @@ class CAmDLTLogging
7878
template<typename T, typename... TArgs>
7979
void logAmRaDebug(T value, TArgs... args)
8080
{
81-
CAmDltWrapper* inst(CAmDltWrapper::instance());
82-
if (!inst->init(DLT_LOG_DEBUG, CAmDLTLogging::Instance()->getContextPointer()))
83-
return;
84-
inst->append(value);
85-
inst->append(args...);
86-
inst->send();
81+
CAmRaAlsaLogging::getContext().debug(value, args...);
8782
}
8883

8984
/**
@@ -94,12 +89,7 @@ void logAmRaDebug(T value, TArgs... args)
9489
template<typename T, typename... TArgs>
9590
void logAmRaInfo(T value, TArgs... args)
9691
{
97-
CAmDltWrapper* inst(CAmDltWrapper::instance());
98-
if (!inst->init(DLT_LOG_INFO, CAmDLTLogging::Instance()->getContextPointer()))
99-
return;
100-
inst->append(value);
101-
inst->append(args...);
102-
inst->send();
92+
CAmRaAlsaLogging::getContext().info(value, args...);
10393
}
10494

10595
/**
@@ -110,14 +100,8 @@ void logAmRaInfo(T value, TArgs... args)
110100
template<typename T, typename... TArgs>
111101
void logAmRaError(T value, TArgs... args)
112102
{
113-
CAmDltWrapper* inst(CAmDltWrapper::instance());
114-
115-
if (!inst->init(DLT_LOG_ERROR, CAmDLTLogging::Instance()->getContextPointer()))
116-
return;
117-
inst->append(value);
118-
inst->append(args...);
119-
inst->send();
103+
CAmRaAlsaLogging::getContext().error(value, args...);
120104
}
121105

122106
} /* namespace am */
123-
#endif /* CAMDLTLOGGING_H_ */
107+
#endif /* CAMRAALSALOGGING_H_ */

PluginRoutingAdapterALSA/src/CAmDLTLogging.cpp renamed to PluginRoutingAdapterALSA/src/CAmRaAlsaLogging.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,33 @@
2626
* For further information see http://www.genivi.org/.
2727
******************************************************************************/
2828

29-
#include "CAmDLTLogging.h"
29+
#include "CAmRaAlsaLogging.h"
30+
3031

3132
using namespace am;
3233

33-
CAmDLTLogging *CAmDLTLogging::mCAmDLTLogging = NULL;
34+
CAmRaAlsaLogging *CAmRaAlsaLogging::mpLogging = NULL;
35+
36+
37+
#define LOGCONTEXT "ALSA"
38+
#define LOGDESCRIPTION "Logging Context for Routing-Adapter ALSA"
3439

35-
CAmDLTLogging::CAmDLTLogging()
40+
CAmRaAlsaLogging::CAmRaAlsaLogging()
41+
: mContext(CAmLogWrapper::instance()->registerContext(LOGCONTEXT, LOGDESCRIPTION))
3642
{
37-
CAmDltWrapper::instance()->registerContext(mContext, CONTEXT, "Context for RoutingAdapter");
3843
}
3944

40-
CAmDLTLogging *CAmDLTLogging::Instance()
45+
CAmRaAlsaLogging *CAmRaAlsaLogging::Instance()
4146
{
42-
if (mCAmDLTLogging == NULL)
47+
if (mpLogging == NULL)
4348
{
44-
mCAmDLTLogging = new CAmDLTLogging();
49+
mpLogging = new CAmRaAlsaLogging();
4550
}
46-
return mCAmDLTLogging;
47-
}
48-
49-
CAmDLTLogging::~CAmDLTLogging()
50-
{
51-
CAmDltWrapper::instance()->unregisterContext(mContext);
51+
return mpLogging;
5252
}
5353

54-
DltContext *CAmDLTLogging::getContextPointer()
54+
CAmRaAlsaLogging::~CAmRaAlsaLogging()
5555
{
56-
return &mContext;
56+
CAmLogWrapper::instance()->unregisterContext(LOGCONTEXT);
57+
mpLogging = NULL;
5758
}

PluginRoutingAdapterALSA/src/CAmRoutingAdapterALSADeviceDetector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include "CAmRoutingAdapterALSAdb.h"
3636
#include "CAmRoutingAdapterALSASender.h"
3737

38-
#include "CAmDLTLogging.h"
38+
#include "CAmRaAlsaLogging.h"
3939

4040
using namespace std;
4141
using namespace am;

PluginRoutingAdapterALSA/src/CAmRoutingAdapterALSAParser.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
#include <stdlib.h> // for getenv()
3434
#include <fstream> //for file operations
3535
#include "CAmRoutingAdapterALSAParser.h"
36-
#include "CAmDLTLogging.h"
37-
38-
DLT_DECLARE_CONTEXT (ALSARoutingAdapterParser)
36+
#include "CAmRaAlsaLogging.h"
3937

4038
using namespace std;
4139
using namespace am;

PluginRoutingAdapterALSA/src/CAmRoutingAdapterALSAProxyDefault.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030

3131
#include "CAmRoutingAdapterALSAProxyDefault.h"
32-
#include "CAmDLTLogging.h"
32+
#include "CAmRaAlsaLogging.h"
3333
#include <cerrno>
3434

3535
using namespace am;

PluginRoutingAdapterALSA/src/CAmRoutingAdapterALSASender.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
#include "TAmPluginTemplate.h"
4141

42-
#include "CAmDLTLogging.h"
42+
#include "CAmRaAlsaLogging.h"
4343

4444
#define DEFAULT_PLUGIN_STREAMING_DIR DEFAULT_PLUGIN_DIR "/streaming"
4545

PluginRoutingAdapterALSA/src/CAmRoutingAdapterALSAVolume.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636
#include "audiomanagertypes.h"
3737
#include "CAmRoutingAdapterALSAVolume.h"
3838
#include "CAmRoutingAdapterALSASender.h"
39-
#include "CAmDLTLogging.h"
40-
41-
DLT_DECLARE_CONTEXT (CRaALSAVolume)
39+
#include "CAmRaAlsaLogging.h"
4240

4341

4442
using namespace am;

PluginRoutingAdapterALSA/src/CAmRoutingAdapterALSAdb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <cassert>
3131
#include <algorithm>
3232
#include "CAmRoutingAdapterALSAdb.h"
33-
#include "CAmDLTLogging.h"
33+
#include "CAmRaAlsaLogging.h"
3434

3535
using namespace std;
3636
using namespace am;

0 commit comments

Comments
 (0)