2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup tag_NSFramework
19 /// \brief Framework wrapper over the logger interface APIs
23 ///////////////////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////////////////
28 #include <native_service/ns_rcs_logger_types.h>
29 #include <native_service/frameworkunified_framework_if.h>
30 #include <native_service/ns_logger_if.h>
31 #include <native_service/nslogutil_cmd_if.h>
32 #include <native_service/ns_message_center_if.h>
34 #include "frameworkunified_framework_core.h"
35 #include "frameworkunified_framework_internal.h"
36 #include "frameworkunified_framework_utility.h"
38 FrameworkunifiedProtocolCallbackHandler rcs_logging_callbacks[] = {
39 { NSRCS_SET_LOG_SETTINGS_REQ, NSRcsSetLogSettings },
40 { NSRCS_GET_LOG_SETTINGS_REQ, NSRcsGetLogSettings },
41 { NSRCS_SET_LOG_MASK_REQ, NSRcsSetLogMask },
42 { NSRCS_SET_LOG_OUT_OPT_REQ, NSRcsSetOutputLogOpts },
43 { NSRCS_SET_LOG_SEVERITY_REQ, NSRcsSetLogSeverity },
47 FrameworkunifiedProtocolCallbackHandler logging_callbacks[] = {
48 { SET_LOG_MASK, FrameworkunifiedSetLogMask },
49 { GET_LOG_MASK, FrameworkunifiedGetLogMask },
50 { SET_LOG_OUT_OPT, FrameworkunifiedSetOutputLogOpts },
51 { GET_LOG_OUT_OPT, FrameworkunifiedGetOutputLogOpts },
52 // { kDebugDumpRequest, FrameworkunifiedDebugDumpRequest }, /// < Added to help Debug Issues with in CCR Radio
53 // Callback attach with frameworkunifieddebug is moved to SystemServices
54 { SET_LOG_SEVERITY, FrameworkunifiedSetLogSeverity },
55 { GET_LOG_SEVERITY, FrameworkunifiedGetLogSeverity },
59 ////////////////////////////////////////////////////////////////////////////////////////////
60 /// FrameworkunifiedNPRegisterNotification
61 ////////////////////////////////////////////////////////////////////////////////////////////
62 EFrameworkunifiedStatus FrameworkunifiedAttachLoggerCallbacksDispatcher(HANDLE hApp) {
63 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
65 if (frameworkunifiedCheckValidAppHandle(hApp)) {
66 eStatus = FrameworkunifiedAttachCallbacksToDispatcher(hApp, "nslogutil", logging_callbacks,
67 static_cast<UI_32>(_countof(logging_callbacks)));
68 // Callback attach with of kDebugDumpRequest with frameworkunifieddebug is moved to SystemServices. Keep only nslogutil.
69 eStatus = (eStatus != eFrameworkunifiedStatusOK) ? eStatus : FrameworkunifiedAttachCallbackToDispatcher(hApp, "nslogutil", kDebugDumpRequest,
70 FrameworkunifiedDebugDumpRequest);
71 eStatus = (eStatus != eFrameworkunifiedStatusOK) ? eStatus : FrameworkunifiedAttachCallbacksToDispatcher(hApp,
74 static_cast<UI_32>(_countof(logging_callbacks)));
75 eStatus = FrameworkunifiedSubscribeNotificationWithCallback(hApp, NTFY_LOGGER_SETCONTROLMASK, FrameworkunifiedSetLogMask);
77 // This is optional only for remote control service. Therefore return value not checked
78 if (eFrameworkunifiedStatusOK != FrameworkunifiedAttachCallbacksToDispatcher(hApp, FRAMEWORKUNIFIED_NS_REMOTECONTROLSERVICE, rcs_logging_callbacks,
79 static_cast<UI_32>(_countof(rcs_logging_callbacks)))) {
80 // LCOV_EXCL_BR_START 15:marco defined in "native_service/ns_logger_if.h"
81 FRAMEWORKUNIFIEDLOG0(ZONE_NS_WAR, __FUNCTION__,
82 " FrameworkunifiedAttachCallbacksToDispatcher failed for rcs_logging_callbacks with FRAMEWORKUNIFIED_NS_REMOTECONTROLSERVICE");
86 eStatus = eFrameworkunifiedStatusInvldParam;
91 ////////////////////////////////////////////////////////////////////////////////////////////
92 /// FrameworkunifiedNPRegisterNotification
93 ////////////////////////////////////////////////////////////////////////////////////////////
94 EFrameworkunifiedStatus FrameworkunifiedSetLogMask(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
95 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
96 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
97 CHANGELOGPARAMS chngLogOpts;
98 FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+");
100 if (FrameworkunifiedGetMsgLength(hApp) == sizeof(CHANGELOGPARAMS)) {
101 if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&chngLogOpts, sizeof(chngLogOpts))) {
102 // Set the mask to the value that was just sent.
103 NsLogSetControlMask(chngLogOpts.uiZoneMask);
105 FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Retervial of Data Failed");
106 eStatus = eFrameworkunifiedStatusErrOther;
109 FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Incorrect message sz");
110 eStatus = eFrameworkunifiedStatusInvldBuf;
113 FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-");
118 ////////////////////////////////////////////////////////////////////////////////////////////
119 /// FrameworkunifiedNPRegisterNotification
120 ////////////////////////////////////////////////////////////////////////////////////////////
121 EFrameworkunifiedStatus FrameworkunifiedGetLogMask(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
122 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
123 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
124 FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+");
126 if (frameworkunifiedCheckValidAppHandle(hApp)) {
127 PCSTR pAppName = FrameworkunifiedGetAppName(hApp);
128 PCSTR pSrcName = FrameworkunifiedGetMsgSrc(hApp);
130 if (NULL != pAppName && NULL != pSrcName) {
131 HANDLE echoBack = McOpenSender(pSrcName);
132 if (NULL != echoBack) {
133 CHANGELOGPARAMS chng_log_params;
135 NsLogGetControlMask(chng_log_params.uiZoneMask);
136 if (eFrameworkunifiedStatusOK != (eStatus = McSend(echoBack, pAppName, GET_LOG_MASK_RESPONSE, sizeof(chng_log_params),
137 &chng_log_params))) {
138 FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Error sending message GET_LOG_MASK_RESPONSE");
144 eStatus = eFrameworkunifiedStatusInvldHandle;
147 eStatus = eFrameworkunifiedStatusNullPointer;
150 eStatus = eFrameworkunifiedStatusInvldParam;
153 FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-");
158 ////////////////////////////////////////////////////////////////////////////////////////////
159 /// FrameworkunifiedNPRegisterNotification
160 ////////////////////////////////////////////////////////////////////////////////////////////
161 EFrameworkunifiedStatus FrameworkunifiedSetOutputLogOpts(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
162 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
163 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
164 CHANGELOGPARAMS chngLogOpts;
165 FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+");
167 if (FrameworkunifiedGetMsgLength(hApp) == sizeof(CHANGELOGPARAMS)) {
168 if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&chngLogOpts, sizeof(chngLogOpts))) {
169 // Set the logging method to the value that was just received.
170 NsLogSetLogMethod(chngLogOpts.uiLogOptions);
172 FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Retervial of Data Failed");
173 eStatus = eFrameworkunifiedStatusErrOther;
176 FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, " Incorrect message sz");
177 eStatus = eFrameworkunifiedStatusInvldBuf;
181 FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-");
186 ////////////////////////////////////////////////////////////////////////////////////////////
187 /// FrameworkunifiedNPRegisterNotification
188 ////////////////////////////////////////////////////////////////////////////////////////////
189 EFrameworkunifiedStatus FrameworkunifiedGetOutputLogOpts(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
190 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
191 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
192 FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+");
194 if (frameworkunifiedCheckValidAppHandle(hApp)) {
195 PCSTR pAppName = FrameworkunifiedGetAppName(hApp);
196 PCSTR pSrcName = FrameworkunifiedGetMsgSrc(hApp);
198 if (NULL != pAppName && NULL != pSrcName) {
199 HANDLE echoBack = McOpenSender(pSrcName);
201 if (NULL != echoBack) {
202 CHANGELOGPARAMS chng_log_params;
204 chng_log_params.uiLogOptions = NsLogGetLogMethod();
205 if (eFrameworkunifiedStatusOK != (eStatus = McSend(echoBack, pAppName, GET_LOG_OUT_OPT_RESPONSE, sizeof(chng_log_params),
206 &chng_log_params))) {
207 FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Error sending message GET_LOG_OUT_OPT_RESPONSE");
213 eStatus = eFrameworkunifiedStatusInvldHandle;
216 eStatus = eFrameworkunifiedStatusNullPointer;
219 eStatus = eFrameworkunifiedStatusInvldParam;
222 FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-");
227 ////////////////////////////////////////////////////////////////////////////////////////////
228 /// FrameworkunifiedSetLogSeverity
229 ////////////////////////////////////////////////////////////////////////////////////////////
230 EFrameworkunifiedStatus FrameworkunifiedSetLogSeverity(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
231 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
232 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
233 CHANGELOGPARAMS l_tChngLogOpts = {};
234 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
236 if (FrameworkunifiedGetMsgLength(hApp) == sizeof(CHANGELOGPARAMS)) {
237 if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tChngLogOpts, sizeof(l_tChngLogOpts))) {
238 // Set the logging method to the value that was just received.
239 NsLogSetSeverity(l_tChngLogOpts.eSeverity);
241 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of log severity data Failed");
242 eStatus = eFrameworkunifiedStatusErrOther;
245 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size CHANGELOGPARAMS");
246 eStatus = eFrameworkunifiedStatusInvldBuf;
249 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
254 ////////////////////////////////////////////////////////////////////////////////////////////
255 /// FrameworkunifiedGetLogSeverity
256 ////////////////////////////////////////////////////////////////////////////////////////////
257 EFrameworkunifiedStatus FrameworkunifiedGetLogSeverity(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
258 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
259 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
260 FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "+");
262 if (frameworkunifiedCheckValidAppHandle(hApp)) {
263 PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
264 PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
266 if (NULL != l_cAppName && NULL != l_cSrcName) {
267 HANDLE l_hEchoBack = McOpenSender(l_cSrcName);
269 if (NULL != l_hEchoBack) {
270 CHANGELOGPARAMS l_tChngLogParams = {};
272 l_tChngLogParams.eSeverity = NsLogGetSeverity();
273 if (eFrameworkunifiedStatusOK != (eStatus = McSend(l_hEchoBack, l_cAppName, GET_LOG_SEVERITY_RESPONSE,
274 sizeof(l_tChngLogParams), &l_tChngLogParams))) {
275 FRAMEWORKUNIFIEDLOG0(ZONE_NS_ERR, __FUNCTION__, "Error sending message GET_LOG_OUT_OPT_RESPONSE");
278 McClose(l_hEchoBack);
281 eStatus = eFrameworkunifiedStatusInvldHandle;
284 eStatus = eFrameworkunifiedStatusNullPointer;
287 eStatus = eFrameworkunifiedStatusInvldParam;
290 FRAMEWORKUNIFIEDLOG0(ZONE_NS_INFO, __FUNCTION__, "-");
295 ////////////////////////////////////////////////////////////////////////////////////////////
296 /// FrameworkunifiedDebugDumpRequest: Calls an Applications FrameworkunifiedOnDebugDump method.
297 ////////////////////////////////////////////////////////////////////////////////////////////
298 EFrameworkunifiedStatus FrameworkunifiedDebugDumpRequest(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
299 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
300 EFrameworkunifiedStatus eStatus = eFrameworkunifiedStatusOK;
301 FRAMEWORKUNIFIEDLOG0(ZONE_NS_DEBUG_DUMP, __FUNCTION__, "+");
302 eStatus = FrameworkunifiedOnDebugDumpInternal(hApp);
303 FRAMEWORKUNIFIEDLOG0(ZONE_NS_DEBUG_DUMP, __FUNCTION__, "+");
308 EFrameworkunifiedStatus NSRcsSetLogSettings(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
309 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
310 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
311 if (frameworkunifiedCheckValidAppHandle(hApp)) {
312 if (FrameworkunifiedGetMsgLength(hApp) == sizeof(TNSRCS_SetLogSettingsReq)) {
313 TNSRCS_SetLogSettingsReq l_tSetLogSettings = {};
315 if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tSetLogSettings, sizeof(l_tSetLogSettings))) {
317 NsLogSetControlMask(l_tSetLogSettings.m_pui32ZoneMask);
318 // set the log output option
319 NsLogSetLogMethod(l_tSetLogSettings.m_ui8OutputLogOption);
320 // set the log severity
321 NsLogSetSeverity(l_tSetLogSettings.m_si32Severity);
322 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Log settings applied");
324 // send the response back with the current settings
325 TNSRCS_SetLogSettingsResp l_tSetLogSettingsResp = {};
326 PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
327 PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
328 HANDLE l_hSendTo = McOpenSender(l_cSrcName);
330 if (NULL != l_hSendTo) {
331 l_tSetLogSettingsResp.m_ui8ClientId = l_tSetLogSettings.m_ui8ClientId;
332 l_tSetLogSettingsResp.m_ui8SetStatus = static_cast<UI_8>(eFrameworkunifiedStatusOK);
334 NsLogGetControlMask(l_tSetLogSettingsResp.m_pui32ZoneMask);
335 l_tSetLogSettingsResp.m_ui8OutputLogOption = NsLogGetLogMethod();
336 l_tSetLogSettingsResp.m_si32Severity = NsLogGetSeverity();
338 if (eFrameworkunifiedStatusOK !=
339 McSend(l_hSendTo, l_cAppName, NSRCS_SET_LOG_SETTINGS_RESP,
340 sizeof(TNSRCS_SetLogSettingsResp), &l_tSetLogSettingsResp)) {
341 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending message "
342 "NSRCS_SET_LOG_SETTINGS_RESP to %s", l_cSrcName);
347 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Sender handle NULL when sending response to %s", l_cSrcName);
350 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of Data Failed");
353 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size. Received: %d expected: %ld",
354 FrameworkunifiedGetMsgLength(hApp),
355 static_cast<long int>(sizeof(TNSRCS_SetLogSettingsReq))); // NOLINT (readability/nolint)
358 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
360 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
361 return eFrameworkunifiedStatusOK;
365 EFrameworkunifiedStatus NSRcsGetLogSettings(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
366 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
367 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
368 if (frameworkunifiedCheckValidAppHandle(hApp)) {
369 if (FrameworkunifiedGetMsgLength(hApp) == sizeof(TNSRCS_GetLogSettingsReq)) {
370 TNSRCS_GetLogSettingsReq l_tGetLogSettings = {};
372 if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tGetLogSettings, sizeof(l_tGetLogSettings))) {
373 // send the response back with the current settings
374 TNSRCS_GetLogSettingsResp l_tGetLogSettingsResp = {};
375 PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
376 PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
377 HANDLE l_hSendTo = McOpenSender(l_cSrcName);
379 if (NULL != l_hSendTo) {
380 l_tGetLogSettingsResp.m_ui8ClientId = l_tGetLogSettings.m_ui8ClientId;
381 NsLogGetZoneTextList(l_tGetLogSettingsResp.m_cZoneList);
382 NsLogGetControlMask(l_tGetLogSettingsResp.m_pui32ZoneMask);
383 l_tGetLogSettingsResp.m_ui8OutputLogOption = NsLogGetLogMethod();
384 l_tGetLogSettingsResp.m_si32Severity = NsLogGetSeverity();
386 if (eFrameworkunifiedStatusOK !=
387 McSend(l_hSendTo, l_cAppName, NSRCS_GET_LOG_SETTINGS_RESP,
388 sizeof(TNSRCS_GetLogSettingsResp), &l_tGetLogSettingsResp)) {
389 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending message "
390 "NSRCS_GET_LOG_SETTINGS_RESP to %s", l_cSrcName);
395 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Sender handle NULL when sending response to %s", l_cSrcName);
398 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of Data Failed");
401 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size. Received: %d expected: %ld",
402 FrameworkunifiedGetMsgLength(hApp),
403 static_cast<long int>(sizeof(TNSRCS_GetLogSettingsReq))); // NOLINT (readability/nolint)
406 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
408 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
409 return eFrameworkunifiedStatusOK;
413 EFrameworkunifiedStatus NSRcsSetLogMask(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
414 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
415 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
416 if (frameworkunifiedCheckValidAppHandle(hApp)) {
417 if (FrameworkunifiedGetMsgLength(hApp) == sizeof(TNSRCS_SetLogSettingsReq)) {
418 TNSRCS_SetLogSettingsReq l_tSetLogSettings = {};
420 if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tSetLogSettings, sizeof(l_tSetLogSettings))) {
422 NsLogSetControlMask(l_tSetLogSettings.m_pui32ZoneMask);
424 // 11 = number of chars in UI_32, 1 - nul char at the end
425 CHAR l_cOutMask[(ZONE_MASK_ARRAY_ELTS * 11) + 1] = {};
426 CHAR l_cMask[12] = {}; // 12 = 11+1: 11 = number of chars in UI_32, 1 - nul char at the end
427 for (UI_32 zoneIndex = 0; zoneIndex < ZONE_MASK_ARRAY_ELTS; zoneIndex++) {
428 std::strncpy(l_cMask, "", 11);
429 snprintf(l_cMask, sizeof(l_cMask), "0x%X,", l_tSetLogSettings.m_pui32ZoneMask[zoneIndex]);
430 std::strncat(l_cOutMask, l_cMask, (sizeof(l_cOutMask) - std::strlen(l_cMask) - 1));
432 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Log settings (zone mask) applied: %s", l_cOutMask);
434 // send the response back with the current settings
435 TNSRCS_SetLogMaskResp l_tSetLogMaskResp = {};
436 PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
437 PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
438 HANDLE l_hSendTo = McOpenSender(l_cSrcName);
440 if (NULL != l_hSendTo) {
441 l_tSetLogMaskResp.m_ui8ClientId = l_tSetLogSettings.m_ui8ClientId;
442 l_tSetLogMaskResp.m_ui8SetStatus = static_cast<UI_8>(eFrameworkunifiedStatusOK);
444 NsLogGetControlMask(l_tSetLogMaskResp.m_pui32ZoneMask);
446 if (eFrameworkunifiedStatusOK !=
447 McSend(l_hSendTo, l_cAppName, NSRCS_SET_LOG_MASK_RESP,
448 sizeof(TNSRCS_SetLogMaskResp), &l_tSetLogMaskResp)) {
449 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending message "
450 "NSRCS_SET_LOG_MASK_RESP to %s", l_cSrcName);
455 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Sender handle NULL when sending response to %s", l_cSrcName);
458 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of Data Failed");
461 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size. Received: %d expected: %ld",
462 FrameworkunifiedGetMsgLength(hApp),
463 static_cast<long int>(sizeof(TNSRCS_SetLogSettingsReq))); // NOLINT (readability/nolint)
466 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
468 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
469 return eFrameworkunifiedStatusOK;
473 EFrameworkunifiedStatus NSRcsSetOutputLogOpts(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
474 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
475 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
476 if (frameworkunifiedCheckValidAppHandle(hApp)) {
477 if (FrameworkunifiedGetMsgLength(hApp) == sizeof(TNSRCS_SetLogSettingsReq)) {
478 TNSRCS_SetLogSettingsReq l_tSetLogSettings = {};
480 if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tSetLogSettings, sizeof(l_tSetLogSettings))) {
481 // set the log output option
482 NsLogSetLogMethod(l_tSetLogSettings.m_ui8OutputLogOption);
483 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Log settings(log output option) applied: %d.",
484 l_tSetLogSettings.m_ui8OutputLogOption);
486 // send the response back with the current settings
487 TNSRCS_SetLogOutOptResp l_tSetLogOutputOptResp = {};
488 PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
489 PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
490 HANDLE l_hSendTo = McOpenSender(l_cSrcName);
492 if (NULL != l_hSendTo) {
493 l_tSetLogOutputOptResp.m_ui8ClientId = l_tSetLogSettings.m_ui8ClientId;
494 l_tSetLogOutputOptResp.m_ui8SetStatus = static_cast<UI_8>(eFrameworkunifiedStatusOK);
496 l_tSetLogOutputOptResp.m_ui8OutputLogOption = NsLogGetLogMethod();
498 if (eFrameworkunifiedStatusOK !=
499 McSend(l_hSendTo, l_cAppName, NSRCS_SET_LOG_OUT_OPT_RESP,
500 sizeof(TNSRCS_SetLogOutOptResp), &l_tSetLogOutputOptResp)) {
501 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending message "
502 "NSRCS_SET_LOG_OUT_OPT_RESP to %s", l_cSrcName);
507 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Sender handle NULL when sending response to %s", l_cSrcName);
510 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of Data Failed");
513 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size. Received: %d expected: %ld",
514 FrameworkunifiedGetMsgLength(hApp),
515 static_cast<long int>(sizeof(TNSRCS_SetLogSettingsReq))); // NOLINT (readability/nolint)
518 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
520 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
521 return eFrameworkunifiedStatusOK;
525 EFrameworkunifiedStatus NSRcsSetLogSeverity(HANDLE hApp) { // LCOV_EXCL_START 7:debug code
526 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
527 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "+");
528 if (frameworkunifiedCheckValidAppHandle(hApp)) {
529 if (FrameworkunifiedGetMsgLength(hApp) == sizeof(TNSRCS_SetLogSettingsReq)) {
530 TNSRCS_SetLogSettingsReq l_tSetLogSettings = {};
532 if (eFrameworkunifiedStatusOK == FrameworkunifiedGetMsgDataOfSize(hApp, (PVOID)&l_tSetLogSettings, sizeof(l_tSetLogSettings))) {
533 // set the log severity
534 NsLogSetSeverity(l_tSetLogSettings.m_si32Severity);
535 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "Log settings(log severity) applied: %d.",
536 l_tSetLogSettings.m_si32Severity);
538 // send the response back with the current settings
539 TNSRCS_SetLogSeverityResp l_tSetLogSeverityResp = {};
540 PCSTR l_cAppName = FrameworkunifiedGetAppName(hApp);
541 PCSTR l_cSrcName = FrameworkunifiedGetMsgSrc(hApp);
542 HANDLE l_hSendTo = McOpenSender(l_cSrcName);
544 if (NULL != l_hSendTo) {
545 l_tSetLogSeverityResp.m_ui8ClientId = l_tSetLogSettings.m_ui8ClientId;
546 l_tSetLogSeverityResp.m_ui8SetStatus = static_cast<UI_8>(eFrameworkunifiedStatusOK);
548 l_tSetLogSeverityResp.m_si32Severity = NsLogGetSeverity();
550 if (eFrameworkunifiedStatusOK !=
551 McSend(l_hSendTo, l_cAppName, NSRCS_SET_LOG_SEVERITY_RESP,
552 sizeof(TNSRCS_SetLogSeverityResp), &l_tSetLogSeverityResp)) {
553 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Error sending message "
554 "NSRCS_SET_LOG_SEVERITY_RESP to %s", l_cSrcName);
559 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Sender handle NULL when sending response to %s", l_cSrcName);
562 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "Retrieval of Data Failed");
565 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, " Incorrect message size. Received: %d expected: %ld",
566 FrameworkunifiedGetMsgLength(hApp),
567 static_cast<long int>(sizeof(TNSRCS_SetLogSettingsReq))); // NOLINT (readability/nolint)
570 FRAMEWORKUNIFIEDLOG(ZONE_NS_ERR, __FUNCTION__, "hApp is NULL");
572 FRAMEWORKUNIFIEDLOG(ZONE_NS_INFO, __FUNCTION__, "-");
573 return eFrameworkunifiedStatusOK;