2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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.
19 * @brief This file defines the diagnostics types.
26 #include <sys/syscall.h>
27 #include <sys/types.h>
33 #include <FAppTypes.h>
35 #include <FBaseSysLog.h>
37 #include "FBase_Log.h"
38 #include "FBase_StringConverter.h"
41 #include <iniparser.h>
44 using namespace Tizen::Base;
48 #define LOG_TAG "OSP_SLP"
49 #define LOG_TAG_NULL ""
52 void __InitializeLogLevel(dictionary *pDic);
53 void __InitializePlatformModule(dictionary *pDic);
55 static const char LOG_TAG_ASSERT[] = "Assert";
56 static const char FILE_DEBUGMODE[] = "/opt/etc/.debugmode";
58 bool iniLoaded = false;
60 static bool appNameLoaded = false;
61 static char appName[LOG_MODULE_NAME_LEN_MAX];
63 static bool envLoaded = false;
64 static bool envPlatformInfoEnabled = false;
66 #define APP_RESERVED(X) NID_APP+X
67 #define BASE_RESERVED(X) NID_BASE+X
68 #define CNT_RESERVED(X) NID_CNT+X
69 #define CTXT_RESERVED(X) NID_CTXT+X
70 #define GRP_RESERVED(X) NID_GRP+X
72 #define IO_RESERVED(X) NID_IO+X
73 #define LCL_RESERVED(X) NID_LCL+X
74 #define LOC_RESERVED(X) NID_LOC+X
75 #define MEDIA_RESERVED(X) NID_MEDIA+X
76 #define MSG_RESERVED(X) NID_MSG+X
78 #define NET_RESERVED(X) NID_NET+X
79 #define SEC_RESERVED(X) NID_SEC+X
80 #define SCL_RESERVED(X) NID_SCL+X
81 #define SYS_RESERVED(X) NID_SYS+X
82 #define TEL_RESERVED(X) NID_TEL+X
84 #define TEXT_RESERVED(X) NID_TEXT+X
85 #define UI_RESERVED(X) NID_UI+X
86 #define UIX_RESERVED(X) NID_UIX+X
87 #define WEB_RESERVED(X) NID_WEB+X
88 #define SHELL_RESERVED(X) NID_SHELL+X
90 static LogInfo logInfo =
93 //OSP Namespace ID ===============================================================
94 {NID_APP, "NID_APP", "Tizen::App", true},
95 {APP_RESERVED(1) , "RESERVED", "", false},
96 {APP_RESERVED(2) , "RESERVED", "", false},
97 {APP_RESERVED(3) , "RESERVED", "", false},
98 {APP_RESERVED(4) , "RESERVED", "", false},
99 {APP_RESERVED(5) , "RESERVED", "", false},
100 {APP_RESERVED(6) , "RESERVED", "", false},
101 {APP_RESERVED(7) , "RESERVED", "", false},
102 {APP_RESERVED(8) , "RESERVED", "", false},
103 {APP_RESERVED(9) , "RESERVED", "", false},
105 {NID_BASE, "NID_BASE", "Tizen::Base", true},
106 {NID_BASE_COL, "NID_BASE_COL", "Tizen::Base::Collection", true},
107 {NID_BASE_RT, "NID_BASE_RT", "Tizen::Base::Runtime", true},
108 {NID_BASE_UTIL, "NID_BASE_UTIL", "Tizen::Base::Utility", true},
109 {BASE_RESERVED(4) , "RESERVED", "", false},
110 {BASE_RESERVED(5) , "RESERVED", "", false},
111 {BASE_RESERVED(6) , "RESERVED", "", false},
112 {BASE_RESERVED(7) , "RESERVED", "", false},
113 {BASE_RESERVED(8) , "RESERVED", "", false},
114 {BASE_RESERVED(9) , "RESERVED", "", false},
116 {NID_CNT, "NID_CNT", "Tizen::Content", true},
117 {CNT_RESERVED(1) , "RESERVED", "", false},
118 {CNT_RESERVED(2) , "RESERVED", "", false},
119 {CNT_RESERVED(3) , "RESERVED", "", false},
120 {CNT_RESERVED(4) , "RESERVED", "", false},
121 {CNT_RESERVED(5) , "RESERVED", "", false},
122 {CNT_RESERVED(6) , "RESERVED", "", false},
123 {CNT_RESERVED(7) , "RESERVED", "", false},
124 {CNT_RESERVED(8) , "RESERVED", "", false},
125 {CNT_RESERVED(9) , "RESERVED", "", false},
127 {NID_CTXT, "NID_CTXT", "Tizen::Context", true},
128 {CTXT_RESERVED(1) , "RESERVED", "", false},
129 {CTXT_RESERVED(2) , "RESERVED", "", false},
130 {CTXT_RESERVED(3) , "RESERVED", "", false},
131 {CTXT_RESERVED(4) , "RESERVED", "", false},
132 {CTXT_RESERVED(5) , "RESERVED", "", false},
133 {CTXT_RESERVED(6) , "RESERVED", "", false},
134 {CTXT_RESERVED(7) , "RESERVED", "", false},
135 {CTXT_RESERVED(8) , "RESERVED", "", false},
136 {CTXT_RESERVED(9) , "RESERVED", "", false},
138 {NID_GRP, "NID_GRP", "Tizen::Graphics", true},
139 {GRP_RESERVED(1) , "RESERVED", "", false},
140 {GRP_RESERVED(2) , "RESERVED", "", false},
141 {GRP_RESERVED(3) , "RESERVED", "", false},
142 {GRP_RESERVED(4) , "RESERVED", "", false},
143 {GRP_RESERVED(5) , "RESERVED", "", false},
144 {GRP_RESERVED(6) , "RESERVED", "", false},
145 {GRP_RESERVED(7) , "RESERVED", "", false},
146 {GRP_RESERVED(8) , "RESERVED", "", false},
147 {GRP_RESERVED(9) , "RESERVED", "", false},
149 {NID_IO, "NID_IO", "Tizen::Io", true},
150 {IO_RESERVED(1) , "RESERVED", "", false},
151 {IO_RESERVED(2) , "RESERVED", "", false},
152 {IO_RESERVED(3) , "RESERVED", "", false},
153 {IO_RESERVED(4) , "RESERVED", "", false},
154 {IO_RESERVED(5) , "RESERVED", "", false},
155 {IO_RESERVED(6) , "RESERVED", "", false},
156 {IO_RESERVED(7) , "RESERVED", "", false},
157 {IO_RESERVED(8) , "RESERVED", "", false},
158 {IO_RESERVED(9) , "RESERVED", "", false},
160 {NID_LCL, "NID_LCL", "Tizen::Locales", true},
161 {LCL_RESERVED(1) , "RESERVED", "", false},
162 {LCL_RESERVED(2) , "RESERVED", "", false},
163 {LCL_RESERVED(3) , "RESERVED", "", false},
164 {LCL_RESERVED(4) , "RESERVED", "", false},
165 {LCL_RESERVED(5) , "RESERVED", "", false},
166 {LCL_RESERVED(6) , "RESERVED", "", false},
167 {LCL_RESERVED(7) , "RESERVED", "", false},
168 {LCL_RESERVED(8) , "RESERVED", "", false},
169 {LCL_RESERVED(9) , "RESERVED", "", false},
171 {NID_LOC, "NID_LOC", "Tizen::Locations", true},
172 {NID_LOC_CTRL, "NID_LOC_CTRL", "Tizen::Locations::Controls", true},
173 {NID_LOC_SVC, "NID_LOC_SVC", "Tizen::Locations::Services", true},
174 {LOC_RESERVED(3) , "RESERVED", "", false},
175 {LOC_RESERVED(4) , "RESERVED", "", false},
176 {LOC_RESERVED(5) , "RESERVED", "", false},
177 {LOC_RESERVED(6) , "RESERVED", "", false},
178 {LOC_RESERVED(7) , "RESERVED", "", false},
179 {LOC_RESERVED(8) , "RESERVED", "", false},
180 {LOC_RESERVED(9) , "RESERVED", "", false},
182 {NID_MEDIA, "NID_MEDIA", "Tizen::Media", true},
183 {MEDIA_RESERVED(1) , "RESERVED", "", false},
184 {MEDIA_RESERVED(2) , "RESERVED", "", false},
185 {MEDIA_RESERVED(3) , "RESERVED", "", false},
186 {MEDIA_RESERVED(4) , "RESERVED", "", false},
187 {MEDIA_RESERVED(5) , "RESERVED", "", false},
188 {MEDIA_RESERVED(6) , "RESERVED", "", false},
189 {MEDIA_RESERVED(7) , "RESERVED", "", false},
190 {MEDIA_RESERVED(8) , "RESERVED", "", false},
191 {MEDIA_RESERVED(9) , "RESERVED", "", false},
193 {NID_MSG, "NID_MSG", "Tizen::Messaging", true},
194 {MSG_RESERVED(1) , "RESERVED", "", false},
195 {MSG_RESERVED(2) , "RESERVED", "", false},
196 {MSG_RESERVED(3) , "RESERVED", "", false},
197 {MSG_RESERVED(4) , "RESERVED", "", false},
198 {MSG_RESERVED(5) , "RESERVED", "", false},
199 {MSG_RESERVED(6) , "RESERVED", "", false},
200 {MSG_RESERVED(7) , "RESERVED", "", false},
201 {MSG_RESERVED(8) , "RESERVED", "", false},
202 {MSG_RESERVED(9) , "RESERVED", "", false},
204 {NID_NET, "NID_NET", "Tizen::Net", true},
205 {NID_NET_BT, "NID_NET_BT", "Tizen::Net::Bluetooth", true},
206 {NID_NET_HTTP, "NID_NET_HTTP", "Tizen::Net::Http", true},
207 {NID_NET_NFC, "NID_NET_NFC", "Tizen::Net::Nfc", true},
208 {NID_NET_SOCK, "NID_NET_SOCK", "Tizen::Net::Sockets", true},
209 {NID_NET_WIFI, "NID_NET_WIFI", "Tizen::Net::Wifi", true},
210 {NET_RESERVED(6) , "RESERVED", "", false},
211 {NET_RESERVED(7) , "RESERVED", "", false},
212 {NET_RESERVED(8) , "RESERVED", "", false},
213 {NET_RESERVED(9) , "RESERVED", "", false},
215 {NID_SEC, "NID_SEC", "Tizen::Security", true},
216 {NID_SEC_CERT, "NID_SEC_CERT", "Tizen::Security::Cert", true},
217 {NID_SEC_CRYPTO, "NID_SEC_CRYPTO", "Tizen::Security::Crypto", true},
218 {SEC_RESERVED(3) , "RESERVED", "", false},
219 {SEC_RESERVED(4) , "RESERVED", "", false},
220 {SEC_RESERVED(5) , "RESERVED", "", false},
221 {SEC_RESERVED(6) , "RESERVED", "", false},
222 {SEC_RESERVED(7) , "RESERVED", "", false},
223 {SEC_RESERVED(8) , "RESERVED", "", false},
224 {SEC_RESERVED(9) , "RESERVED", "", false},
226 {NID_SCL, "NID_SCL", "Tizen::Social", true},
227 {SCL_RESERVED(1) , "RESERVED", "", false},
228 {SCL_RESERVED(2) , "RESERVED", "", false},
229 {SCL_RESERVED(3) , "RESERVED", "", false},
230 {SCL_RESERVED(4) , "RESERVED", "", false},
231 {SCL_RESERVED(5) , "RESERVED", "", false},
232 {SCL_RESERVED(6) , "RESERVED", "", false},
233 {SCL_RESERVED(7) , "RESERVED", "", false},
234 {SCL_RESERVED(8) , "RESERVED", "", false},
235 {SCL_RESERVED(9) , "RESERVED", "", false},
237 {NID_SYS, "NID_SYS", "Tizen::System", true},
238 {SYS_RESERVED(1) , "RESERVED", "", false},
239 {SYS_RESERVED(2) , "RESERVED", "", false},
240 {SYS_RESERVED(3) , "RESERVED", "", false},
241 {SYS_RESERVED(4) , "RESERVED", "", false},
242 {SYS_RESERVED(5) , "RESERVED", "", false},
243 {SYS_RESERVED(6) , "RESERVED", "", false},
244 {SYS_RESERVED(7) , "RESERVED", "", false},
245 {SYS_RESERVED(8) , "RESERVED", "", false},
246 {SYS_RESERVED(9) , "RESERVED", "", false},
248 {NID_TEL, "NID_TEL", "Tizen::Telephony", true},
249 {TEL_RESERVED(1) , "RESERVED", "", false},
250 {TEL_RESERVED(2) , "RESERVED", "", false},
251 {TEL_RESERVED(3) , "RESERVED", "", false},
252 {TEL_RESERVED(4) , "RESERVED", "", false},
253 {TEL_RESERVED(5) , "RESERVED", "", false},
254 {TEL_RESERVED(6) , "RESERVED", "", false},
255 {TEL_RESERVED(7) , "RESERVED", "", false},
256 {TEL_RESERVED(8) , "RESERVED", "", false},
257 {TEL_RESERVED(9) , "RESERVED", "", false},
259 {NID_TEXT, "NID_TEXT", "Tizen::Text", true},
260 {TEXT_RESERVED(1) , "RESERVED", "", false},
261 {TEXT_RESERVED(2) , "RESERVED", "", false},
262 {TEXT_RESERVED(3) , "RESERVED", "", false},
263 {TEXT_RESERVED(4) , "RESERVED", "", false},
264 {TEXT_RESERVED(5) , "RESERVED", "", false},
265 {TEXT_RESERVED(6) , "RESERVED", "", false},
266 {TEXT_RESERVED(7) , "RESERVED", "", false},
267 {TEXT_RESERVED(8) , "RESERVED", "", false},
268 {TEXT_RESERVED(9) , "RESERVED", "", false},
270 {NID_UI, "NID_UI", "Tizen::Ui", true},
271 {NID_UI_ANIM, "NID_UI_ANIM", "Tizen::Ui::Animations", true},
272 {NID_UI_CTRL, "NID_UI_CTRL", "Tizen::Ui::Controls", true},
273 {NID_UI_EFFECT, "NID_UI_EFFECT", "Tizen::Ui::Effects", true},
274 {NID_UI_IME, "NID_UI_IME", "Tizen::Ui::Ime", true},
275 {NID_UI_SCENES, "NID_UI_SCENES", "Tizen::Ui::Scenes", true},
276 {UI_RESERVED(6) , "RESERVED", "", false},
277 {UI_RESERVED(7) , "RESERVED", "", false},
278 {UI_RESERVED(8) , "RESERVED", "", false},
279 {UI_RESERVED(9) , "RESERVED", "", false},
281 {NID_UIX, "NID_UIX", "Tizen::Uix", true},
282 {NID_UIX_SPEECH, "NID_UIX_SPEECH", "Tizen::Uix::Speech", true},
283 {UIX_RESERVED(2) , "RESERVED", "", false},
284 {UIX_RESERVED(3) , "RESERVED", "", false},
285 {UIX_RESERVED(4) , "RESERVED", "", false},
286 {UIX_RESERVED(5) , "RESERVED", "", false},
287 {UIX_RESERVED(6) , "RESERVED", "", false},
288 {UIX_RESERVED(7) , "RESERVED", "", false},
289 {UIX_RESERVED(8) , "RESERVED", "", false},
290 {UIX_RESERVED(9) , "RESERVED", "", false},
292 {NID_WEB, "NID_WEB", "Tizen::Web", true},
293 {NID_WEB_CTRL, "NID_WEB_CTRL", "Tizen::Web::Controls", true},
294 {NID_WEB_JSON, "NID_WEB_JSON", "Tizen::Web::Json", true},
295 {WEB_RESERVED(3) , "RESERVED", "", false},
296 {WEB_RESERVED(4) , "RESERVED", "", false},
297 {WEB_RESERVED(5) , "RESERVED", "", false},
298 {WEB_RESERVED(6) , "RESERVED", "", false},
299 {WEB_RESERVED(7) , "RESERVED", "", false},
300 {WEB_RESERVED(8) , "RESERVED", "", false},
301 {WEB_RESERVED(9) , "RESERVED", "", false},
303 {NID_SHELL, "NID_SHELL", "Tizen::Shell", true},
304 {SHELL_RESERVED(1) , "RESERVED", "", false},
305 {SHELL_RESERVED(2) , "RESERVED", "", false},
306 {SHELL_RESERVED(3) , "RESERVED", "", false},
307 {SHELL_RESERVED(4) , "RESERVED", "", false},
308 {SHELL_RESERVED(5) , "RESERVED", "", false},
309 {SHELL_RESERVED(6) , "RESERVED", "", false},
310 {SHELL_RESERVED(7) , "RESERVED", "", false},
311 {SHELL_RESERVED(8) , "RESERVED", "", false},
312 {SHELL_RESERVED(9) , "RESERVED", "", false}
316 // Other properties ===========================================================
320 true, //platformInfoEnabled;
321 true, //platformExceptionEnabled;
323 true, // applicationInfoEnabled
324 true, // applicationDebugEnabled
325 true, // applicationExceptionEnabled
330 AppLogInternal(const char* pFunction, int lineNumber, const char* pFormat, ...)
334 if (!logInfo.applicationInfoEnabled)
339 va_start(args, pFormat);
341 __PrintLog(static_cast<_LogType>(LOG_INFO), pFunction, lineNumber, pFormat, args);
347 AppLogTagInternal(const char* pTag, const char* pFunction, int lineNumber, const char* pFormat, ...)
351 if (!logInfo.applicationInfoEnabled)
356 va_start(args, pFormat);
358 __PrintLogTag(pTag, static_cast<_LogType>(LOG_INFO), pFunction, lineNumber, pFormat, args);
364 AppLogDebugInternal(const char* pFunction, int lineNumber, const char* pFormat, ...)
368 if (!logInfo.applicationDebugEnabled)
373 va_start(args, pFormat);
375 __PrintLog(static_cast<_LogType>(LOG_DEBUG), pFunction, lineNumber, pFormat, args);
381 AppLogDebugTagInternal(const char* pTag, const char* pFunction, int lineNumber, const char* pFormat, ...)
385 if (!logInfo.applicationDebugEnabled)
390 va_start(args, pFormat);
392 __PrintLogTag(pTag, static_cast<_LogType>(LOG_DEBUG), pFunction, lineNumber, pFormat, args);
398 AppLogExceptionInternal(const char* pFunction, int lineNumber, const char* pFormat, ...)
402 if (!logInfo.applicationExceptionEnabled)
407 va_start(args, pFormat);
409 __PrintLog(static_cast<_LogType>(LOG_EXCEPTION), pFunction, lineNumber, pFormat, args);
415 AppLogExceptionTagInternal(const char* pTag, const char* pFunction, int lineNumber, const char* pFormat, ...)
419 if (!logInfo.applicationExceptionEnabled)
424 va_start(args, pFormat);
426 __PrintLogTag(pTag, static_cast<_LogType>(LOG_EXCEPTION), pFunction, lineNumber, pFormat, args);
432 AppassertInternal(const char* pFunction, int lineNumber)
434 char logBody[LOG_LEN_MAX];
437 char logTag[LOG_MODULE_NAME_LEN_MAX];
439 vconf_get_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &appDebug);
440 platformDebug = (0 == access(FILE_DEBUGMODE, F_OK));
442 snprintf(logTag, LOG_MODULE_NAME_LEN_MAX, "%s", appName);
443 logTag[LOG_MODULE_NAME_LEN_MAX - 1] = '\0';
445 if( (platformDebug == false) && (appDebug == 0) )
447 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > App assertion passed due to debug mode off!", pFunction, lineNumber);
448 ALOG(LOG_ERROR, logTag, "%s", logBody);
452 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > AppAssert!", pFunction, lineNumber);
453 ALOG(LOG_ERROR, logTag, "%s", logBody);
459 AppassertfInternal(const char* expr, const char* pFunction, int lineNumber, const char* pFormat, ...)
461 char logBody[LOG_LEN_MAX];
465 va_start(args, pFormat);
467 vconf_get_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &appDebug);
468 platformDebug = (0 == access(FILE_DEBUGMODE, F_OK));
470 if( (platformDebug == false) && (appDebug == 0) )
472 snprintf(logBody, LOG_LEN_MAX, "App assertion passed due to debug mode off! : %s", pFormat);
473 __PrintLog(static_cast<_LogType>(LOG_USER), pFunction, lineNumber, logBody, args);
478 __PrintLog(static_cast<_LogType>(LOG_USER), pFunction, lineNumber, pFormat, args);
487 SysLogInternal(unsigned long nid, const char* pFunction, int lineNumber, const char* pFormat, ...)
491 if (unlikely(!envLoaded))
493 int ret = access("/home/developer/.platforminfologgingmode", F_OK);
496 envPlatformInfoEnabled = true;
500 envPlatformInfoEnabled = false;
506 if (!envPlatformInfoEnabled)
511 if (!logInfo.platformInfoEnabled)
516 va_start(args, pFormat);
518 __PrintSysLog(static_cast<_LogType>(LOG_INFO), static_cast<LogID>(nid), pFunction, lineNumber, pFormat, args);
524 SysLogExceptionInternal(unsigned long nid, result r, const char* pFunction, int lineNumber, const char* pFormat, ...)
530 if (!logInfo.platformExceptionEnabled)
535 va_start(args, pFormat);
537 __PrintSysLog(static_cast<_LogType>(LOG_EXCEPTION), static_cast<LogID>(nid), pFunction, lineNumber, pFormat, args);
543 SysLogTagInternal(unsigned long nid, const char* pTag, const char* pFunction, int lineNumber, const char* pFormat, ...)
547 if (unlikely(!envLoaded))
549 int ret = access("/home/developer/.platforminfologgingmode", F_OK);
552 envPlatformInfoEnabled = true;
556 envPlatformInfoEnabled = false;
562 if (!envPlatformInfoEnabled)
567 if (!logInfo.platformInfoEnabled)
572 va_start(args, pFormat);
574 __PrintSysLogTag(pTag, static_cast<_LogType>(LOG_INFO), static_cast<LogID>(nid), pFunction, lineNumber, pFormat, args);
580 SysLogExceptionTagInternal(unsigned long nid, const char* pTag, result r, const char* pFunction, int lineNumber,
588 if (!logInfo.platformExceptionEnabled)
593 va_start(args, pFormat);
595 __PrintSysLogTag(pTag, static_cast<_LogType>(LOG_EXCEPTION), static_cast<LogID>(nid), pFunction, lineNumber, pFormat, args);
602 SysAssertInternal(const char* pFileName, int lineNumber, const char* pFunction)
606 char logBody[LOG_LEN_MAX];
608 platformDebug = (0 == access(FILE_DEBUGMODE, F_OK));
615 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > SysAssert!", pFunction, lineNumber);
617 ALOG(LOG_ERROR, LOG_TAG_ASSERT, "%s", logBody);
623 SysAssertfInternal(const char* expr, const char* pFunction, int lineNumber, const char* pFormat, ...)
625 char logBody[LOG_LEN_MAX];
629 platformDebug = (0 == access(FILE_DEBUGMODE, F_OK));
636 va_start(args, pFormat);
638 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
639 logBody[LOG_LEN_MAX - 1] = '\0';
641 ALOG_VA(LOG_ERROR, LOG_TAG_ASSERT, logBody, args);
649 SysPropagateInternal(const char* pFunction, int lineNumber, unsigned long nid, result r)
651 char logBody[PROPAGATION_LEN_MAX];
652 snprintf(logBody, PROPAGATION_LEN_MAX, "%s(%d) > [%s] Propagating to caller...", pFunction, lineNumber, GetErrorMessage(r));
654 char logTag[LOG_MODULE_NAME_LEN_MAX];
655 snprintf(logTag, LOG_MODULE_NAME_LEN_MAX, "%s", __GetModuleName(static_cast<LogID>(nid)));
657 ALOG(LOG_ERROR, logTag, "%s", logBody);
661 SysTryReturnResultInternal(unsigned long id, result r, const char* pFunction, int lineNumber, const char* pFormat, ...)
668 if (!logInfo.platformExceptionEnabled)
675 __InitializeLogInfo();
678 if (!__GetEnableInfo(static_cast<LogID>(id)))
683 va_start(args, pFormat);
685 char logBody[LOG_LEN_MAX];
686 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > [%s] %s", pFunction, lineNumber, GetErrorMessage(r), pFormat);
687 logBody[LOG_LEN_MAX -1] = '\0';
689 char logTag[LOG_MODULE_NAME_LEN_MAX];
691 snprintf(logTag, LOG_MODULE_NAME_LEN_MAX, "%s", __GetModuleName(static_cast<LogID>(id)));
692 logTag[LOG_MODULE_NAME_LEN_MAX - 1] = '\0';
694 ALOG_VA(LOG_ERROR, logTag, logBody, args);
702 __PrintLog(_LogType type, const char* pFunction, int lineNumber, const char* pFormat, va_list args)
704 if (unlikely(!iniLoaded))
706 __InitializeLogInfo();
709 char logBody[LOG_LEN_MAX];
710 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
711 logBody[LOG_LEN_MAX - 1] = '\0';
713 char logTag[LOG_MODULE_NAME_LEN_MAX];
715 if (unlikely(!appNameLoaded))
717 appNameLoaded = true;
718 strncpy(appName, appinfo_get_execname(), LOG_MODULE_NAME_LEN_MAX);
720 snprintf(logTag, LOG_MODULE_NAME_LEN_MAX, "%s", appName);
722 logTag[LOG_MODULE_NAME_LEN_MAX - 1] = '\0';
726 case static_cast<_LogType>(LOG_INFO):
727 ALOG_VA(LOG_INFO, logTag, logBody, args);
730 case static_cast<_LogType>(LOG_DEBUG):
731 ALOG_VA(LOG_DEBUG, logTag, logBody, args);
734 case static_cast<_LogType>(LOG_EXCEPTION):
735 ALOG_VA(LOG_ERROR, logTag, logBody, args);
738 case static_cast<_LogType>(LOG_USER):
739 ALOG_VA(LOG_ERROR, logTag, logBody, args);
743 ALOG_VA(LOG_DEBUG, LOG_TAG_NULL, logBody, args);
749 __PrintLogTag(const char* pTag, _LogType type, const char* pFunction, int lineNumber, const char* pFormat, va_list args)
751 if (unlikely(!iniLoaded))
753 __InitializeLogInfo();
756 char logBody[LOG_LEN_MAX];
757 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
758 logBody[LOG_LEN_MAX -1] = '\0';
760 char logTag[LOG_TAG_LEN_MAX];
762 snprintf(logTag, LOG_TAG_LEN_MAX, "%s", pTag);
763 logTag[LOG_TAG_LEN_MAX - 1] = '\0';
767 case static_cast<_LogType>(LOG_INFO):
768 ALOG_VA(LOG_INFO, logTag, logBody, args);
771 case static_cast<_LogType>(LOG_DEBUG):
772 ALOG_VA(LOG_DEBUG, logTag, logBody, args);
775 case static_cast<_LogType>(LOG_EXCEPTION):
776 ALOG_VA(LOG_ERROR, logTag, logBody, args);
779 case static_cast<_LogType>(LOG_USER):
780 ALOG_VA(LOG_ERROR, logTag, logBody, args);
784 ALOG_VA(LOG_DEBUG, LOG_TAG_NULL, logBody, args);
791 __PrintSysLog(_LogType type, LogID id, const char* pFunction, int lineNumber, const char* pFormat, va_list args)
793 if (unlikely(!iniLoaded))
795 __InitializeLogInfo();
798 if (!__GetEnableInfo(static_cast<LogID>(id)))
803 char logBody[LOG_LEN_MAX];
804 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
805 logBody[LOG_LEN_MAX -1] = '\0';
807 char logTag[LOG_MODULE_NAME_LEN_MAX];
809 snprintf(logTag, LOG_MODULE_NAME_LEN_MAX, "%s", __GetModuleName(static_cast<LogID>(id)));
810 logTag[LOG_MODULE_NAME_LEN_MAX - 1] = '\0';
814 case static_cast<_LogType>(LOG_INFO):
815 ALOG_VA(LOG_INFO, logTag, logBody, args);
818 case static_cast<_LogType>(LOG_DEBUG):
819 ALOG_VA(LOG_DEBUG, logTag, logBody, args);
822 case static_cast<_LogType>(LOG_EXCEPTION):
823 ALOG_VA(LOG_ERROR, logTag, logBody, args);
826 case static_cast<_LogType>(LOG_USER):
827 ALOG_VA(LOG_ERROR, logTag, logBody, args);
831 ALOG_VA(LOG_DEBUG, LOG_TAG_NULL, logBody, args);
837 __PrintSysLogTag(const char* pTag, _LogType type, LogID id, const char* pFunction, int lineNumber, const char* pFormat, va_list args)
839 if (unlikely(!iniLoaded))
841 __InitializeLogInfo();
844 if (!__GetEnableInfo(static_cast<LogID>(id)))
849 char logBody[LOG_LEN_MAX];
850 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
851 logBody[LOG_LEN_MAX -1] = '\0';
853 char logTag[LOG_MODULE_NAME_LEN_MAX + LOG_TAG_LEN_MAX];
855 snprintf(logTag, LOG_MODULE_NAME_LEN_MAX + LOG_TAG_LEN_MAX, "%s | %s", __GetModuleName(static_cast<LogID>(id)), pTag);
856 logTag[LOG_MODULE_NAME_LEN_MAX + LOG_TAG_LEN_MAX - 1] = '\0';
860 case static_cast<_LogType>(LOG_INFO):
861 ALOG_VA(LOG_INFO, logTag, logBody, args);
864 case static_cast<_LogType>(LOG_DEBUG):
865 ALOG_VA(LOG_DEBUG, logTag, logBody, args);
868 case static_cast<_LogType>(LOG_EXCEPTION):
869 ALOG_VA(LOG_ERROR, logTag, logBody, args);
872 case static_cast<_LogType>(LOG_USER):
873 ALOG_VA(LOG_ERROR, logTag, logBody, args);
877 ALOG_VA(LOG_DEBUG, LOG_TAG_NULL, logBody, args);
883 __GetModuleName(LogID id)
885 return logInfo.logTable[id].logModuleName;
889 __GetEnableInfo(LogID id)
891 return logInfo.logTable[id].loggingEnabled;
895 __InitializeLogInfo()
900 pDic = iniparser_load("/opt/usr/etc/system-log.ini");
904 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] opening ini file failed.\n");
908 __InitializeLogLevel(pDic);
909 __InitializePlatformModule(pDic);
911 iniparser_freedict(pDic);
915 __InitializeLogLevel(dictionary *pDic)
917 char sectApp[]="Application";
918 char sectPlatform[]="Platform";
920 char entryInfo[]="INFO";
921 char entryDebug[]="DEBUG";
922 char entryException[]="EXCEPTION";
927 char keyString[LOG_MODULE_NAME_LEN_MAX*2];
930 sprintf(keyString, "%s:%s", sectApp, entryInfo);
931 keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0';
932 pVal = iniparser_getstr(pDic, keyString);
935 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Application/INFO failed.\n");
938 retVal = strcmp(strYes, pVal);
939 logInfo.applicationInfoEnabled = (retVal == 0);
941 sprintf(keyString, "%s:%s", sectApp, entryDebug);
942 keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0';
943 pVal = iniparser_getstr(pDic, keyString);
946 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Application/DEBUG failed.\n");
949 retVal = strcmp(strYes, pVal);
950 logInfo.applicationDebugEnabled = (retVal == 0);
952 sprintf(keyString, "%s:%s", sectApp, entryException);
953 keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0';
954 pVal = iniparser_getstr(pDic, keyString);
957 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Application/EXCEPTION failed.\n");
960 retVal = strcmp(strYes, pVal);
961 logInfo.applicationExceptionEnabled = (retVal == 0);
963 sprintf(keyString, "%s:%s", sectPlatform, entryInfo);
964 keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0';
965 pVal = iniparser_getstr(pDic, keyString);
968 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Platform/INFO failed.\n");
971 retVal = strcmp(strYes, pVal);
972 logInfo.platformInfoEnabled = (retVal == 0);
974 sprintf(keyString, "%s:%s", sectPlatform, entryException);
975 keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0';
976 pVal = iniparser_getstr(pDic, keyString);
979 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Platform/EXCEPTION failed.\n");
982 retVal = strcmp(strYes, pVal);
983 logInfo.platformExceptionEnabled = (retVal == 0);
987 __InitializePlatformModule(dictionary *pDic)
989 char sectModule[]="PlatformModules";
995 char keyString[LOG_MODULE_NAME_LEN_MAX*2];
997 for (int i = 0; i < NID_MAX; i++)
1000 sprintf(keyString, "%s:%s", sectModule, logInfo.logTable[i].logIDName);
1001 keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0';
1002 pVal = iniparser_getstr(pDic, keyString);
1005 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding PlatformModules/%ls failed.\n", logInfo.logTable[i].logIDName);
1009 retVal = strcmp(strYes, pVal);
1010 logInfo.logTable[i].loggingEnabled = (retVal == 0);