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.
28 #include <sys/syscall.h>
29 #include <sys/types.h>
30 #include <FAppTypes.h>
32 #include <FBaseSysLog.h>
33 #include "FBase_Log.h"
34 #include "FBase_StringConverter.h"
35 #include "FApp_AppInfo.h"
38 #include <iniparser.h>
41 using namespace Tizen::Base;
42 using namespace Tizen::Io;
43 using namespace Tizen::Base::Collection;
44 using namespace Tizen::App;
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 char* pAppName = _StringConverter::CopyToCharArrayN(_AppInfo::GetAppExecutableName());
719 strncpy(appName, pAppName, LOG_MODULE_NAME_LEN_MAX);
722 snprintf(logTag, LOG_MODULE_NAME_LEN_MAX, "%s", appName);
724 logTag[LOG_MODULE_NAME_LEN_MAX - 1] = '\0';
728 case static_cast<_LogType>(LOG_INFO):
729 ALOG_VA(LOG_INFO, logTag, logBody, args);
732 case static_cast<_LogType>(LOG_DEBUG):
733 ALOG_VA(LOG_DEBUG, logTag, logBody, args);
736 case static_cast<_LogType>(LOG_EXCEPTION):
737 ALOG_VA(LOG_ERROR, logTag, logBody, args);
740 case static_cast<_LogType>(LOG_USER):
741 ALOG_VA(LOG_ERROR, logTag, logBody, args);
745 ALOG_VA(LOG_DEBUG, LOG_TAG_NULL, logBody, args);
751 __PrintLogTag(const char* pTag, _LogType type, const char* pFunction, int lineNumber, const char* pFormat, va_list args)
753 if (unlikely(!iniLoaded))
755 __InitializeLogInfo();
758 char logBody[LOG_LEN_MAX];
759 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
760 logBody[LOG_LEN_MAX -1] = '\0';
762 char logTag[LOG_TAG_LEN_MAX];
764 snprintf(logTag, LOG_TAG_LEN_MAX, "%s", pTag);
765 logTag[LOG_TAG_LEN_MAX - 1] = '\0';
769 case static_cast<_LogType>(LOG_INFO):
770 ALOG_VA(LOG_INFO, logTag, logBody, args);
773 case static_cast<_LogType>(LOG_DEBUG):
774 ALOG_VA(LOG_DEBUG, logTag, logBody, args);
777 case static_cast<_LogType>(LOG_EXCEPTION):
778 ALOG_VA(LOG_ERROR, logTag, logBody, args);
781 case static_cast<_LogType>(LOG_USER):
782 ALOG_VA(LOG_ERROR, logTag, logBody, args);
786 ALOG_VA(LOG_DEBUG, LOG_TAG_NULL, logBody, args);
793 __PrintSysLog(_LogType type, LogID id, const char* pFunction, int lineNumber, const char* pFormat, va_list args)
795 if (unlikely(!iniLoaded))
797 __InitializeLogInfo();
800 if (!__GetEnableInfo(static_cast<LogID>(id)))
805 char logBody[LOG_LEN_MAX];
806 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
807 logBody[LOG_LEN_MAX -1] = '\0';
809 char logTag[LOG_MODULE_NAME_LEN_MAX];
811 snprintf(logTag, LOG_MODULE_NAME_LEN_MAX, "%s", __GetModuleName(static_cast<LogID>(id)));
812 logTag[LOG_MODULE_NAME_LEN_MAX - 1] = '\0';
816 case static_cast<_LogType>(LOG_INFO):
817 ALOG_VA(LOG_INFO, logTag, logBody, args);
820 case static_cast<_LogType>(LOG_DEBUG):
821 ALOG_VA(LOG_DEBUG, logTag, logBody, args);
824 case static_cast<_LogType>(LOG_EXCEPTION):
825 ALOG_VA(LOG_ERROR, logTag, logBody, args);
828 case static_cast<_LogType>(LOG_USER):
829 ALOG_VA(LOG_ERROR, logTag, logBody, args);
833 ALOG_VA(LOG_DEBUG, LOG_TAG_NULL, logBody, args);
839 __PrintSysLogTag(const char* pTag, _LogType type, LogID id, const char* pFunction, int lineNumber, const char* pFormat, va_list args)
841 if (unlikely(!iniLoaded))
843 __InitializeLogInfo();
846 if (!__GetEnableInfo(static_cast<LogID>(id)))
851 char logBody[LOG_LEN_MAX];
852 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
853 logBody[LOG_LEN_MAX -1] = '\0';
855 char logTag[LOG_MODULE_NAME_LEN_MAX + LOG_TAG_LEN_MAX];
857 snprintf(logTag, LOG_MODULE_NAME_LEN_MAX + LOG_TAG_LEN_MAX, "%s | %s", __GetModuleName(static_cast<LogID>(id)), pTag);
858 logTag[LOG_MODULE_NAME_LEN_MAX + LOG_TAG_LEN_MAX - 1] = '\0';
862 case static_cast<_LogType>(LOG_INFO):
863 ALOG_VA(LOG_INFO, logTag, logBody, args);
866 case static_cast<_LogType>(LOG_DEBUG):
867 ALOG_VA(LOG_DEBUG, logTag, logBody, args);
870 case static_cast<_LogType>(LOG_EXCEPTION):
871 ALOG_VA(LOG_ERROR, logTag, logBody, args);
874 case static_cast<_LogType>(LOG_USER):
875 ALOG_VA(LOG_ERROR, logTag, logBody, args);
879 ALOG_VA(LOG_DEBUG, LOG_TAG_NULL, logBody, args);
885 __GetModuleName(LogID id)
887 return logInfo.logTable[id].logModuleName;
891 __GetEnableInfo(LogID id)
893 return logInfo.logTable[id].loggingEnabled;
897 __InitializeLogInfo()
902 pDic = iniparser_load("/opt/usr/etc/system-log.ini");
906 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] opening ini file failed.\n");
910 __InitializeLogLevel(pDic);
911 __InitializePlatformModule(pDic);
913 iniparser_freedict(pDic);
917 __InitializeLogLevel(dictionary *pDic)
919 char sectApp[]="Application";
920 char sectPlatform[]="Platform";
922 char entryInfo[]="INFO";
923 char entryDebug[]="DEBUG";
924 char entryException[]="EXCEPTION";
929 char keyString[LOG_MODULE_NAME_LEN_MAX*2];
932 sprintf(keyString, "%s:%s", sectApp, entryInfo);
933 keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0';
934 pVal = iniparser_getstr(pDic, keyString);
937 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Application/INFO failed.\n");
940 retVal = strcmp(strYes, pVal);
941 logInfo.applicationInfoEnabled = (retVal == 0);
943 sprintf(keyString, "%s:%s", sectApp, entryDebug);
944 keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0';
945 pVal = iniparser_getstr(pDic, keyString);
948 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Application/DEBUG failed.\n");
951 retVal = strcmp(strYes, pVal);
952 logInfo.applicationDebugEnabled = (retVal == 0);
954 sprintf(keyString, "%s:%s", sectApp, entryException);
955 keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0';
956 pVal = iniparser_getstr(pDic, keyString);
959 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Application/EXCEPTION failed.\n");
962 retVal = strcmp(strYes, pVal);
963 logInfo.applicationExceptionEnabled = (retVal == 0);
965 sprintf(keyString, "%s:%s", sectPlatform, entryInfo);
966 keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0';
967 pVal = iniparser_getstr(pDic, keyString);
970 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Platform/INFO failed.\n");
973 retVal = strcmp(strYes, pVal);
974 logInfo.platformInfoEnabled = (retVal == 0);
976 sprintf(keyString, "%s:%s", sectPlatform, entryException);
977 keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0';
978 pVal = iniparser_getstr(pDic, keyString);
981 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Platform/EXCEPTION failed.\n");
984 retVal = strcmp(strYes, pVal);
985 logInfo.platformExceptionEnabled = (retVal == 0);
989 __InitializePlatformModule(dictionary *pDic)
991 char sectModule[]="PlatformModules";
997 char keyString[LOG_MODULE_NAME_LEN_MAX*2];
999 for (int i = 0; i < NID_MAX; i++)
1002 sprintf(keyString, "%s:%s", sectModule, logInfo.logTable[i].logIDName);
1003 keyString[LOG_MODULE_NAME_LEN_MAX*2-1] = '\0';
1004 pVal = iniparser_getstr(pDic, keyString);
1007 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding PlatformModules/%ls failed.\n", logInfo.logTable[i].logIDName);
1011 retVal = strcmp(strYes, pVal);
1012 logInfo.logTable[i].loggingEnabled = (retVal == 0);