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_SS_LoggerService
19 /// \brief This file supports error event logging.
21 ///////////////////////////////////////////////////////////////////////////////
25 #include <boost/bind.hpp>
27 #include <sys/types.h>
30 #include <native_service/frameworkunified_framework_if.h>
31 #include <native_service/frameworkunified_multithreading.h>
32 #include <native_service/ns_sharedmem.h>
33 #include <native_service/ns_sharedmem_reader.h>
34 #include <native_service/ns_ringbuffer.h>
35 #include <native_service/ns_logger_if.h>
36 #include <system_service/ss_sm_client_if.h>
37 #include <system_service/ss_logger_service_protocol.h>
38 #include <system_service/ss_services.h>
39 #include <system_service/ss_templates.h>
40 #include <native_service/cl_process.h>
41 #include <native_service/cl_lockid.h>
44 #include "loggerservicedebug_loggerservicelog.h"
45 #include "loggerservicedebug_thread_if.h"
46 #include "ss_logger_error_event.h"
47 #include "ss_logger_service_callbacks.h"
48 #include "ss_logger_scrshot.h"
49 #include "ss_logger_fs_directory.h"
50 #include "ss_logger_common.h"
51 #include "ss_logger_types.h"
53 EFrameworkunifiedStatus SSLogger_SendtoSM(HANDLE f_hApp, TLoggingArtifact f_artifact) {
54 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
55 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
56 l_eStatus = SendLogArtifactRequestToSystemManager(f_artifact.ArtifactId);
57 if (eFrameworkunifiedStatusOK != l_eStatus) {
61 " Error. SendLogArtifactRequestToSystemManager returned: %d for artifact ID: %d",
62 l_eStatus, f_artifact.ArtifactId);
64 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
68 EFrameworkunifiedStatus SSLogger_SendtoSelf(HANDLE f_hApp, TLoggingArtifact f_artifact) {
69 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
70 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusNullPointer;
71 if (NULL != f_hApp) { // LCOV_EXCL_BR_LINE 6: double check
72 l_eStatus = FrameworkunifiedSendSelf(f_hApp, SS_LOGGER_ERROR_EVENT_ARTIFACT_REQ,
73 sizeof(f_artifact.ArtifactId),
74 &f_artifact.ArtifactId);
76 if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
77 // LCOV_EXCL_START 4: NSFW error case.
78 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
82 " Error. FrameworkunifiedSendSelf(SS_LOGGER_ERROR_EVENT_ARTIFACT_REQ) returned error: %d for artifact ID: %d.",
83 l_eStatus, f_artifact.ArtifactId);
87 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
90 ///////////////////////////////////////////////////////////////////////////
91 // Function : SendLogArtifactResponseToSelf
92 // brief : Collect frameworkunifiedlog artifact and return a response to
94 ///////////////////////////////////////////////////////////////////////////
95 EFrameworkunifiedStatus CErrorEvent::SendLogArtifactResponseToSelf(
96 HANDLE f_hApp, EArtifactId f_artifactId,
97 std::string f_artifactFilePathAndName) {
98 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
99 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
100 ARTIFACT_RESPONSE l_artifactResponse;
102 l_artifactResponse.ArtifactId = f_artifactId;
104 strncpy(l_artifactResponse.FilePathAndName, f_artifactFilePathAndName.c_str(),
105 sizeof(l_artifactResponse.FilePathAndName) - 1);
107 l_eStatus = FrameworkunifiedSendSelf(f_hApp, SS_SM_ERROR_EVENT_ARTIFACT_RSPN,
108 sizeof(l_artifactResponse), &l_artifactResponse);
110 LOG_STATUS_IF_ERRORED(l_eStatus,
111 "FrameworkunifiedSendSelf(SS_SM_ERROR_EVENT_ARTIFACT_RSPN)");
113 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
117 ///////////////////////////////////////////////////////////////////////////
118 // Function : OnObtainLoggerserviceLogRequest
119 // brief : Collect frameworkunifiedlog artifact and return a response to
121 ///////////////////////////////////////////////////////////////////////////
122 EFrameworkunifiedStatus CErrorEvent::OnObtainLoggerserviceLogRequest(HANDLE f_hApp) {
123 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
124 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
125 std::string dir_path = DEBUG_LOG_PATH_DIR;
127 l_eStatus = CFSDirectory::CreateDirectory(dir_path);
128 if (l_eStatus != eFrameworkunifiedStatusOK) {
129 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Create FRAMEWORKUNIFIEDLOG tmp directory %d",
132 UI_32 l_DumpSize = 0;
133 std::string src_file_path;
134 std::string dst_file_path;
137 bool log_clear = true;
139 switch (m_errorEventNtfData.EventType) {
141 case eErrorEventTypeUserInvokedUserForceReset:
142 case eErrorEventTypeUserInvokedCollectAllLogs:
143 case eErrorEventTypeUserInvokedCollectScreenShot:
144 case eErrorEventTypeUserInvokedCollectInterfaceunifiedLogs:
145 case eErrorEventTypeDiagEvent:
146 case eErrorEventTypeCanEvent:
147 case eErrorEventTypeDtcEvent:
148 case eErrorEventTypeModuleInvokedCollectDebugLogs:
150 case eErrorEventTypeUserInvokedCollectDevLogs:
157 num = NSLogGetFrameworkunifiedlogFileTotalNum();
158 for (UI_32 cont = 0; cont < num; cont++) {
159 file_name = NSLogGetFrameworkunifiedlogFileName(cont);
160 if (file_name == NULL) {
163 src_file_path = FRAMEWORKUNIFIEDLOG_RAMDISC_PATH;
164 src_file_path.append("/");
165 src_file_path.append(file_name);
166 dst_file_path = DEBUG_LOG_PATH_DIR;
167 dst_file_path.append("/");
168 dst_file_path.append(file_name);
169 CNSRingBuffer* l_pLoggerservicelog;
171 index = NSLogGetFrameworkunifiedlogIndex(src_file_path.c_str());
172 l_pLoggerservicelog = new (std::nothrow) CNSRingBuffer(
173 src_file_path, 0, index + LOCK_NSLOG_ACCES_IF_1);
174 if (l_pLoggerservicelog == NULL) { // LCOV_EXCL_BR_LINE 5: new's error case
175 // LCOV_EXCL_START 5: new's error case
176 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
177 l_eStatus = eFrameworkunifiedStatusInvldHandle;
178 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
179 "Error: FRAMEWORKUNIFIEDLOG RingBuffer handle is NULL %s",
180 src_file_path.c_str());
182 } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->Open())) {
183 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
184 "Error: FRAMEWORKUNIFIEDLOG RingBuffer Open failed %s %d",
185 src_file_path.c_str(), l_eStatus);
186 } else if (eFrameworkunifiedStatusOK
187 != (l_eStatus = l_pLoggerservicelog->DumpToFile(dst_file_path.c_str(),
189 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
190 "Error: FRAMEWORKUNIFIEDLOG RingBuffer DumpToFile failed %s %d",
191 src_file_path.c_str(), l_eStatus);
193 if (NULL != l_pLoggerservicelog) { // LCOV_EXCL_BR_LINE 5: new's error case
195 if (eFrameworkunifiedStatusOK != (l_eStatus = l_pLoggerservicelog->ClearBuf())) {
196 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
197 "Error: FRAMEWORKUNIFIEDLOG RingBuffer ClearBuf failed %s %d",
198 src_file_path.c_str(), l_eStatus);
201 (void) l_pLoggerservicelog->Close();
202 delete l_pLoggerservicelog;
205 l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdInterfaceunifiedDebugLog,
207 LOG_STATUS_IF_ERRORED(
208 l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdInterfaceunifiedDebugLog)");
210 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
214 ///////////////////////////////////////////////////////////////////////////
215 // Function : OnObtainLoggerserviceLogRequest
216 // brief : Collect frameworkunifiedlog artifact and return a response to
218 ///////////////////////////////////////////////////////////////////////////
219 EFrameworkunifiedStatus CErrorEvent::OnObtainTransmitLogRequest(HANDLE f_hApp) {
220 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
221 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
222 std::string l_RootPath;
224 l_eStatus = m_pReaderWriterControl->FlushCache(eReaderWriterLogTransmit);
225 LOG_STATUS_IF_ERRORED(l_eStatus, "m_pReaderWriterControl->FlushCache(eReaderWriterLogTransmit)");
226 l_RootPath = TRANSMIT_LOG_PATH_FN;
227 if (access(l_RootPath.c_str(), R_OK) != 0) {
230 l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdTransmitLog,
233 LOG_STATUS_IF_ERRORED(l_eStatus,
234 "SendLogArtifactResponseToSelf(eArtifactIdTransmitLog)");
236 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
240 ///////////////////////////////////////////////////////////////////////////
241 // Function : OnObtainLoggerserviceLogRequest
242 // brief : Collect frameworkunifiedlog artifact and return a response to
244 ///////////////////////////////////////////////////////////////////////////
245 EFrameworkunifiedStatus CErrorEvent::OnObtainPerformanceLogRequest(HANDLE f_hApp) {
246 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
247 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
249 l_eStatus = m_pReaderWriterControl->FlushCache(eReaderWriterLogPerformance);
250 LOG_STATUS_IF_ERRORED(
252 "m_pReaderWriterControl->FlushCache(eReaderWriterLogPerformance)");
253 l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdPerformanceLog,
254 PERFORMANCE_LOG_PATH_FN);
256 LOG_STATUS_IF_ERRORED(
257 l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdPerformanceLog)");
259 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
263 ///////////////////////////////////////////////////////////////////////////
264 // Function : OnObtainScreenShotRequest
265 // brief : Collect screen shot artifact from PLM and return a response
267 ///////////////////////////////////////////////////////////////////////////
268 EFrameworkunifiedStatus CErrorEvent::OnObtainScreenShotRequest(HANDLE f_hApp) {
269 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
271 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusFail;
273 l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdScreenShot,
275 LOG_STATUS_IF_ERRORED(
276 l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdScreenShot)");
277 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
281 ///////////////////////////////////////////////////////////////////////////
282 // Function : OnObtainScreenShotResponse
283 // brief : Callback from PLM when the screen shot file has been written
284 // to storage. The data received contains the file path and
285 // name to the written screen shot file. See
286 // SS_LOGGER_SCREENCAPTURE_EVT_ACK.
287 ///////////////////////////////////////////////////////////////////////////
288 EFrameworkunifiedStatus CErrorEvent::OnObtainScreenShotResponse(HANDLE f_hApp) {
289 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
290 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
291 STScreenCaptureEvt l_ScreenCaptureEvtAck;
293 if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg<STScreenCaptureEvt>(f_hApp, l_ScreenCaptureEvtAck))) { // LCOV_EXCL_BR_LINE 200:To ensure success // NOLINT[whitespace/line_length]
294 // LCOV_EXCL_START 200:To ensure success
295 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
296 LOG_ERROR("ReadMsg()");
299 if (FALSE == l_ScreenCaptureEvtAck.fSucessful) {
303 " Error. Screen shot acquisition failed. l_ScreenCaptureEvtAck.fSucessful == FALSE.");
304 l_ScreenCaptureEvtAck.strNameAndLocation[0] = '\0';
307 l_eStatus = SendLogArtifactResponseToSelf(
308 f_hApp, eArtifactIdScreenShot,
309 l_ScreenCaptureEvtAck.strNameAndLocation); // LCOV_EXCL_BR_LINE 11:Unexpected branch
311 LOG_STATUS_IF_ERRORED( // LCOV_EXCL_BR_LINE 5:macro
312 l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdScreenShot)");
315 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
319 ///////////////////////////////////////////////////////////////////////////
320 // Function : OnObtainKernelLogInfoRequest
321 // brief : Collect kernel log artifact and return a response to
323 ///////////////////////////////////////////////////////////////////////////
324 EFrameworkunifiedStatus CErrorEvent::OnObtainKernelLogInfoRequest(HANDLE f_hApp) {
325 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
327 EFrameworkunifiedStatus l_eStatus = CreateKernelLog(f_hApp, SS_LOGGER_KLOG_GET);
329 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
333 ///////////////////////////////////////////////////////////////////////////
334 // Function : OnObtainDRInitialLogRequest
335 // brief : Collect DRInitialLog artifact and return a response to
337 ///////////////////////////////////////////////////////////////////////////
338 EFrameworkunifiedStatus CErrorEvent::OnObtainDRInitialLogRequest(HANDLE f_hApp) {
339 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
340 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
341 UI_32 l_DumpSize = 0;
343 CNSSharedMemReader* l_pDRInitial = new (std::nothrow) CNSSharedMemReader(
344 SHMEM_DRINITIALLOG, FALSE);
346 if (NULL == l_pDRInitial) { // LCOV_EXCL_BR_LINE 5: new's error case
347 l_eStatus = eFrameworkunifiedStatusInvldHandle;
348 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRInitial SharedMem handle is NULL");
349 } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pDRInitial->Open())) {
350 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRInitial Open failed %d", l_eStatus);
351 } else if (eFrameworkunifiedStatusOK
352 != (l_eStatus = l_pDRInitial->DumpToFile(DRINITIAL_LOG_PATH_FN,
354 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRInitial DumpToFile failed %d",
357 l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdDRInitialLog,
358 DRINITIAL_LOG_PATH_FN);
359 LOG_STATUS_IF_ERRORED(
360 l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdDRInitialLog)");
363 if (NULL != l_pDRInitial) { // LCOV_EXCL_BR_LINE 5: new's error case
364 (void) l_pDRInitial->Close();
367 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
371 ///////////////////////////////////////////////////////////////////////////
372 // Function : OnObtainDRLocationLogRequest
373 // brief : Collect DRLocationLog artifact and return a response to
375 ///////////////////////////////////////////////////////////////////////////
376 EFrameworkunifiedStatus CErrorEvent::OnObtainDRLocationLogRequest(HANDLE f_hApp) {
377 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
378 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
379 UI_32 l_DumpSize = 0;
381 CNSSharedMemReader* l_pDRLocation = new (std::nothrow) CNSSharedMemReader(
382 SHMEM_DRLOCATIONLOG, FALSE);
384 if (NULL == l_pDRLocation) { // LCOV_EXCL_BR_LINE 5: new's error case
385 l_eStatus = eFrameworkunifiedStatusInvldHandle;
386 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRInitial SharedMem handle is NULL");
387 } else if (eFrameworkunifiedStatusOK != (l_eStatus = l_pDRLocation->Open())) {
388 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRLocation Open failed %d",
390 } else if (eFrameworkunifiedStatusOK
391 != (l_eStatus = l_pDRLocation->DumpToFile(DRLOCATION_LOG_PATH_FN,
393 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: DRLocation DumpToFile failed %d",
396 l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdDRLocationLog,
397 DRLOCATION_LOG_PATH_FN);
399 LOG_STATUS_IF_ERRORED(
400 l_eStatus, "SendLogArtifactResponseToSelf(eArtifactIdDRLocationLog)");
403 if (NULL != l_pDRLocation) { // LCOV_EXCL_BR_LINE 5: new's error case
404 (void) l_pDRLocation->Close();
405 delete l_pDRLocation;
408 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
412 ///////////////////////////////////////////////////////////////////////////
413 // Function : OnClearAllLogRequest
414 // brief : Callback from LoggerService when the event log file has been delete
415 // from storage. The data received contains the file path.
416 ///////////////////////////////////////////////////////////////////////////
417 EFrameworkunifiedStatus CErrorEvent::OnClearAllLogRequest(HANDLE f_hApp) {
418 std::string clear_file_path = CLEAR_LOG_PATH_FN;
419 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
420 EFrameworkunifiedStatus l_eStatus;
422 if (CFSDirectory::RemoveSubDirectory(clear_file_path)) {
423 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
424 "SS_Logger Clear %s directory delete successful.",
425 clear_file_path.c_str());
427 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
428 "SS_Logger Clear %s directory delete failed.",
429 clear_file_path.c_str());
432 clear_file_path = "/var/local/lib/basesystem/nv/BS/ss/logger_service/rwdata/log2/awlog/";
433 if (CFSDirectory::RemoveSubDirectory(clear_file_path)) {
434 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
435 "SS_Logger Clear %s directory delete successful.",
436 clear_file_path.c_str());
438 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
439 "SS_Logger Clear %s directory delete failed.",
440 clear_file_path.c_str());
443 clear_file_path = "/var/local/lib/basesystem/nv/BS/ss/logger_service/rwdata/log2/core/";
444 if (CFSDirectory::RemoveSubDirectory(clear_file_path)) {
445 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
446 "SS_Logger Clear %s directory delete successful.",
447 clear_file_path.c_str());
449 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
450 "SS_Logger Clear %s directory delete failed.",
451 clear_file_path.c_str());
454 l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdClearAllLog,
455 clear_file_path.c_str());
456 LOG_STATUS_IF_ERRORED(l_eStatus,
457 "SendLogArtifactResponseToSelf(eArtifactIdClearAllLog)");
458 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
462 ///////////////////////////////////////////////////////////////////////////
463 // Function : OnNaviLogRequest
464 // brief : Callback from LoggerService when the event log file has been xxxxxx BUGBUG
465 // from storage. The data received contains the file path.
466 ///////////////////////////////////////////////////////////////////////////
467 EFrameworkunifiedStatus CErrorEvent::OnNaviLogRequest(HANDLE f_hApp) {
468 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
469 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
471 EFrameworkunifiedStatus naviLog_status;
472 switch (m_errorEventNtfData.EventType) {
473 case eErrorEventTypeProcessCrash:
474 case eErrorEventTypeProcessExit:
475 case eErrorEventTypeHeartBeatFailure:
476 case eErrorEventTypeSystemLowMemory:
477 case eErrorEventTypeBootMicroReset:
478 case eErrorEventTypeModConnFailed:
479 case eErrorEventTypeStartRespFailed:
480 case eErrorEventTypeModuleInvokedResetRequest:
481 case eErrorEventTypeGroupRelaunch:
482 naviLog_status = SaveNaviLog(epssdmsdtGENERIC_ERROR_RESET);
485 naviLog_status = SaveNaviLog(epssdmsdtNORMAL_RESET);
488 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Error: Fail to save Navi Log %d",
491 l_eStatus = SendLogArtifactResponseToSelf(f_hApp, eArtifactIdNaviLog, "");
492 LOG_STATUS_IF_ERRORED(l_eStatus,
493 "SendLogArtifactResponseToSelf(eArtifactIdNaviLog)");
494 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
498 EFrameworkunifiedStatus CErrorEvent::CheckPathForArtifact(HANDLE f_hApp,
499 TLoggingArtifact f_artifact) {
500 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
501 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusInvldParam;
504 if (f_artifact.Information.Cb.Type == eCbTypePath) {
505 l_Path = f_artifact.Information.Cb.Path;
506 if (access(l_Path.c_str(), R_OK) != 0) {
507 FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__,
508 "File/Directory %s not found. Returning empty string.",
512 l_eStatus = SendLogArtifactResponseToSelf(f_hApp, f_artifact.ArtifactId,
515 LOG_STATUS_IF_ERRORED(l_eStatus, "SendLogArtifactResponseToSelf()");
518 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
522 /* Read all messages remaining in the ring buffer. (allowed for non-root) */
523 #define SYSLOG_ACTION_READ_ALL 3
524 /* Return size of the log buffer */
525 #define SYSLOG_ACTION_SIZE_BUFFER 10
527 EFrameworkunifiedStatus CErrorEvent::CreateKernelLog(HANDLE f_hApp,
528 SS_LOGGER_KLOG_OPE_TYPE type) {
529 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
530 EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK;
536 len = klogctl(SYSLOG_ACTION_SIZE_BUFFER, NULL, 0);
537 if (len < 0) { // LCOV_EXCL_BR_LINE 5: klogctl's error case
538 // LCOV_EXCL_START 5: klogctl's error case
539 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
540 l_eStatus = eFrameworkunifiedStatusFail;
541 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
542 "Error. Failed to get syslog buffer size: %d, %s", errno,
546 buf = reinterpret_cast<char*>(malloc(len));
547 if (buf != NULL) { // LCOV_EXCL_BR_LINE 5: new's error case
548 len = klogctl(SYSLOG_ACTION_READ_ALL, buf, len);
549 if ((len < 0) || (len == 0)) { // LCOV_EXCL_BR_LINE 5: klogctl's error case
550 // LCOV_EXCL_START 5: klogctl's error case
551 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
552 l_eStatus = eFrameworkunifiedStatusFail;
553 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
554 "Error. Failed to read syslog buffer: %d, %s", errno,
558 std::string file_put_path = "";
559 EArtifactId artifact_id = eArtifactIdMaxValue;
561 case SS_LOGGER_KLOG_GET:
562 file_put_path = KERNEL_LOG_PATH_FN;
563 artifact_id = eArtifactIdKernelLog;
564 fd = open(file_put_path.c_str(),
565 O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
567 case SS_LOGGER_KBOOTLOG_CREATE:
568 file_put_path = KERNEL_BOOT_LOG_PATH_FN;
569 artifact_id = eArtifactIdKernelBootLog;
570 fd = open(file_put_path.c_str(),
571 O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
579 l_eStatus = eFrameworkunifiedStatusFail;
580 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
581 "Error. Failed to open file: %s: %d, %s",
582 file_put_path.c_str(), errno, strerror(errno));
584 wr_len = write(fd, buf, len);
585 if (wr_len == -1) { // LCOV_EXCL_BR_LINE 5: write's error case
586 // LCOV_EXCL_START 5: write's error case
587 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
588 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__,
589 " Error. File write failed. errno: %d, %s", errno,
596 if (SS_LOGGER_KLOG_GET == type) {
597 l_eStatus = SendLogArtifactResponseToSelf(f_hApp, artifact_id,
598 file_put_path.c_str());
599 if (eFrameworkunifiedStatusOK != l_eStatus) { // LCOV_EXCL_BR_LINE 4: NSFW error case.
600 // LCOV_EXCL_START 4: NSFW error case.
601 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
605 "SendLogArtifactResponseToSelf failed. EFrameworkunifiedStatus:%d, ArtifactID:%d, Path:%s",
606 l_eStatus, artifact_id, file_put_path.c_str());
614 // LCOV_EXCL_START 5: new's error case
615 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
616 l_eStatus = eFrameworkunifiedStatusFail;
617 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Memory allocation Failed %s",
622 FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");