ADTF  3.18.3
adtf_remote_logging_intf.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <adtf_utils.h>
10 #include <adtfucom3/adtf_ucom3.h>
11 
12 namespace adtf
13 {
14 namespace remote
15 {
16 namespace ant
17 {
18 
23 class ILogging
24 {
25  public:
27  ADTF_IID(ILogging, "logging.ant.remote.adtf");
28 
30  static constexpr const tChar* const DEFAULT_NAME = "logging";
31 
32  public:
39  virtual size_t CreateLogBuffer(tTimeStamp nTimeout) = 0;
40 
46  virtual tResult ReleaseLogBuffer(size_t nBufferID) = 0;
47 
53  virtual const char* GetBufferContent(size_t nBufferID) = 0;
54 };
55 
61 inline tResult parse_logging_rpc_buffer(const char* strInput, adtf::util::log::logger oLogger)
62 {
63  while (*strInput != '\0')
64  {
65  const char* pItemStart = strInput;
66  adtf::util::cParserHelper::SeekChars(strInput, "\t", true);
67  if (*strInput == '\0')
68  {
69  break;
70  }
71 
72  tTimeStamp nTimeStamp = adtf::util::cString(pItemStart, strInput - pItemStart).AsInt64();
73 
74 
75  strInput += 1;
76  pItemStart = strInput;
77  adtf::util::cParserHelper::SeekChars(strInput, "\t", true);
78  if (*strInput == '\0')
79  {
80  break;
81  }
82 
83  uint32_t value = adtf::util::cString(pItemStart, strInput - pItemStart).AsUInt32();
84  if (value > std::numeric_limits<uint8_t>::max())
85  {
86  // The given value is too large to be downcasted to uint8_t. And it is surely no
87  // valid loglevel. We cannot process this request.
88  RETURN_ERROR_DESC(ERR_INVALID_ARG, "Detected value which is greater than the maximum possible value of nLogLevel");
89  }
90 
91  // after the above check we are safe to convert the value to uint8_t.
92  uint8_t nLogLevel = static_cast<uint8_t>(value);
93  strInput += 1;
94  pItemStart = strInput;
95  adtf::util::cParserHelper::SeekChars(strInput, "\t", true);
96  if (*strInput == '\0')
97  {
98  break;
99  }
100 
101  adtf::util::cString strMessage = adtf::util::cString(pItemStart, strInput - pItemStart).Unescape();
102 
103  strInput += 1;
104  pItemStart = strInput;
105  adtf::util::cParserHelper::SeekChars(strInput, "\n", true);
106  if (*strInput == '\0')
107  {
108  break;
109  }
110 
111  adtf::util::cString strSource = adtf::util::cString(pItemStart, strInput - pItemStart).Unescape();
112 
113  if (nTimeStamp == 0 && nLogLevel == 0)
114  {
115  break;
116  }
117  oLogger({nTimeStamp, nLogLevel, strMessage, strSource});
118  }
120 }
121 
122 }
123 
124 using ant::ILogging;
126 
127 }
128 }
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
char tChar
The tChar defines the type for platform character set (platform and compiler dependent type).
#define RETURN_ERROR_DESC(_code,...)
Same as RETURN_ERROR(_error) using a printf like parameter list for detailed error description.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
tUInt32 AsUInt32() const
This function converts the string to an integer value.
Definition: string.h:2066
tInt64 AsInt64() const
This function converts the string to an integer value.
Definition: string.h:2115
_myType & Unescape()
Escape control characters.
Definition: string.h:1872
The Remote logging interface.
virtual tResult ReleaseLogBuffer(size_t nBufferID)=0
Releases a log buffer.
virtual size_t CreateLogBuffer(tTimeStamp nTimeout)=0
Creates a new log buffer.
static constexpr const tChar *const DEFAULT_NAME
Default rpc object server name within an ADTF system.
ADTF_IID(ILogging, "logging.ant.remote.adtf")
RPC IID of the Clock.
virtual const char * GetBufferContent(size_t nBufferID)=0
Returns the content of a log buffer.
std::function< tVoid(const tLogEntry &sEntry)> logger
Logger interface definition.
string_base< cStackString > cString
cString implementation for a stack string which works on stack if string is lower than A_UTILS_DEFAUL...
Definition: string.h:2778
tResult parse_logging_rpc_buffer(const char *strInput, adtf::util::log::logger oLogger)
This method parses the return value of ILogging::GetBufferContent().
Namespace for entire ADTF SDK.