ADTF
Loading...
Searching...
No Matches
adtf_remote_logging_intf.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <adtf_utils.h>
11
12namespace adtf
13{
14namespace remote
15{
16namespace ant
17{
18
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
61inline 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
124using ant::ILogging;
126
127}
128}
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
#define RETURN_ERROR_DESC(_code,...)
Same as RETURN_ERROR(_error) using a printf like parameter list for detailed error description.
Definition result.h:44
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
Definition adtf_remote_logging_intf.h:24
virtual const char * GetBufferContent(size_t nBufferID)=0
virtual size_t CreateLogBuffer(tTimeStamp nTimeout)=0
static constexpr const tChar *const DEFAULT_NAME
Default rpc object server name within an ADTF System.
Definition adtf_remote_logging_intf.h:30
virtual tResult ReleaseLogBuffer(size_t nBufferID)=0
ADTF_IID(ILogging, "logging.ant.remote.adtf")
RPC IID of the Clock.
Namespace for all functionality of the ADTF Remote SDK provided since v3.0.
Definition adtf_remote_clock_intf.h:16
tResult parse_logging_rpc_buffer(const char *strInput, adtf::util::log::logger oLogger)
Definition adtf_remote_logging_intf.h:61
Namespace for the ADTF Remote SDK.
Definition adtf_client_connector.h:16
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14