2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
20 * @brief This file defines the diagnostics types.
29 #include <sys/syscall.h>
30 #include <sys/types.h>
31 #include <FIoRegistry.h>
33 #include <FAppTypes.h>
35 #include <FBaseSysLog.h>
36 #include "FBase_Log.h"
37 #include "FBase_StringConverter.h"
38 #include "FApp_AppInfo.h"
40 using namespace Tizen::Base;
41 using namespace Tizen::Io;
42 using namespace Tizen::Base::Collection;
43 using namespace Tizen::App;
47 #define LOG_TAG "OSP_SLP"
48 #define LOG_TAG_NULL ""
51 static const char LOG_TAG_ASSERT[] = "Assert";
53 bool iniLoaded = false;
55 static bool appNameLoaded = false;
56 static char appName[LOG_MODULE_NAME_LEN_MAX];
58 static bool envLoaded = false;
59 static bool envPlatformInfoEnabled = true;
61 #define APP_RESERVED(X) NID_APP+X
62 #define BASE_RESERVED(X) NID_BASE+X
63 #define CNT_RESERVED(X) NID_CNT+X
64 #define CTXT_RESERVED(X) NID_CTXT+X
65 #define GRP_RESERVED(X) NID_GRP+X
67 #define IO_RESERVED(X) NID_IO+X
68 #define LCL_RESERVED(X) NID_LCL+X
69 #define LOC_RESERVED(X) NID_LOC+X
70 #define MEDIA_RESERVED(X) NID_MEDIA+X
71 #define MSG_RESERVED(X) NID_MSG+X
73 #define NET_RESERVED(X) NID_NET+X
74 #define SEC_RESERVED(X) NID_SEC+X
75 #define SCL_RESERVED(X) NID_SCL+X
76 #define SYS_RESERVED(X) NID_SYS+X
77 #define TEL_RESERVED(X) NID_TEL+X
79 #define TEXT_RESERVED(X) NID_TEXT+X
80 #define UI_RESERVED(X) NID_UI+X
81 #define UIX_RESERVED(X) NID_UIX+X
82 #define WEB_RESERVED(X) NID_WEB+X
83 #define SHELL_RESERVED(X) NID_SHELL+X
88 //OSP Namespace ID ===============================================================
89 {NID_APP, "NID_APP", "Tizen::App", true},
90 {APP_RESERVED(1) , "RESERVED", "", false},
91 {APP_RESERVED(2) , "RESERVED", "", false},
92 {APP_RESERVED(3) , "RESERVED", "", false},
93 {APP_RESERVED(4) , "RESERVED", "", false},
94 {APP_RESERVED(5) , "RESERVED", "", false},
95 {APP_RESERVED(6) , "RESERVED", "", false},
96 {APP_RESERVED(7) , "RESERVED", "", false},
97 {APP_RESERVED(8) , "RESERVED", "", false},
98 {APP_RESERVED(9) , "RESERVED", "", false},
100 {NID_BASE, "NID_BASE", "Tizen::Base", true},
101 {NID_BASE_COL, "NID_BASE_COL", "Tizen::Base::Collection", true},
102 {NID_BASE_RT, "NID_BASE_RT", "Tizen::Base::Runtime", true},
103 {NID_BASE_UTIL, "NID_BASE_UTIL", "Tizen::Base::Utility", true},
104 {BASE_RESERVED(4) , "RESERVED", "", false},
105 {BASE_RESERVED(5) , "RESERVED", "", false},
106 {BASE_RESERVED(6) , "RESERVED", "", false},
107 {BASE_RESERVED(7) , "RESERVED", "", false},
108 {BASE_RESERVED(8) , "RESERVED", "", false},
109 {BASE_RESERVED(9) , "RESERVED", "", false},
111 {NID_CNT, "NID_CNT", "Tizen::Content", true},
112 {CNT_RESERVED(1) , "RESERVED", "", false},
113 {CNT_RESERVED(2) , "RESERVED", "", false},
114 {CNT_RESERVED(3) , "RESERVED", "", false},
115 {CNT_RESERVED(4) , "RESERVED", "", false},
116 {CNT_RESERVED(5) , "RESERVED", "", false},
117 {CNT_RESERVED(6) , "RESERVED", "", false},
118 {CNT_RESERVED(7) , "RESERVED", "", false},
119 {CNT_RESERVED(8) , "RESERVED", "", false},
120 {CNT_RESERVED(9) , "RESERVED", "", false},
122 {NID_CTXT, "NID_CTXT", "Tizen::Context", true},
123 {CTXT_RESERVED(1) , "RESERVED", "", false},
124 {CTXT_RESERVED(2) , "RESERVED", "", false},
125 {CTXT_RESERVED(3) , "RESERVED", "", false},
126 {CTXT_RESERVED(4) , "RESERVED", "", false},
127 {CTXT_RESERVED(5) , "RESERVED", "", false},
128 {CTXT_RESERVED(6) , "RESERVED", "", false},
129 {CTXT_RESERVED(7) , "RESERVED", "", false},
130 {CTXT_RESERVED(8) , "RESERVED", "", false},
131 {CTXT_RESERVED(9) , "RESERVED", "", false},
133 {NID_GRP, "NID_GRP", "Tizen::Graphics", true},
134 {GRP_RESERVED(1) , "RESERVED", "", false},
135 {GRP_RESERVED(2) , "RESERVED", "", false},
136 {GRP_RESERVED(3) , "RESERVED", "", false},
137 {GRP_RESERVED(4) , "RESERVED", "", false},
138 {GRP_RESERVED(5) , "RESERVED", "", false},
139 {GRP_RESERVED(6) , "RESERVED", "", false},
140 {GRP_RESERVED(7) , "RESERVED", "", false},
141 {GRP_RESERVED(8) , "RESERVED", "", false},
142 {GRP_RESERVED(9) , "RESERVED", "", false},
144 {NID_IO, "NID_IO", "Tizen::Io", true},
145 {IO_RESERVED(1) , "RESERVED", "", false},
146 {IO_RESERVED(2) , "RESERVED", "", false},
147 {IO_RESERVED(3) , "RESERVED", "", false},
148 {IO_RESERVED(4) , "RESERVED", "", false},
149 {IO_RESERVED(5) , "RESERVED", "", false},
150 {IO_RESERVED(6) , "RESERVED", "", false},
151 {IO_RESERVED(7) , "RESERVED", "", false},
152 {IO_RESERVED(8) , "RESERVED", "", false},
153 {IO_RESERVED(9) , "RESERVED", "", false},
155 {NID_LCL, "NID_LCL", "Tizen::Locales", true},
156 {LCL_RESERVED(1) , "RESERVED", "", false},
157 {LCL_RESERVED(2) , "RESERVED", "", false},
158 {LCL_RESERVED(3) , "RESERVED", "", false},
159 {LCL_RESERVED(4) , "RESERVED", "", false},
160 {LCL_RESERVED(5) , "RESERVED", "", false},
161 {LCL_RESERVED(6) , "RESERVED", "", false},
162 {LCL_RESERVED(7) , "RESERVED", "", false},
163 {LCL_RESERVED(8) , "RESERVED", "", false},
164 {LCL_RESERVED(9) , "RESERVED", "", false},
166 {NID_LOC, "NID_LOC", "Tizen::Locations", true},
167 {NID_LOC_CTRL, "NID_LOC_CTRL", "Tizen::Locations::Controls", true},
168 {NID_LOC_SVC, "NID_LOC_SVC", "Tizen::Locations::Services", true},
169 {LOC_RESERVED(3) , "RESERVED", "", false},
170 {LOC_RESERVED(4) , "RESERVED", "", false},
171 {LOC_RESERVED(5) , "RESERVED", "", false},
172 {LOC_RESERVED(6) , "RESERVED", "", false},
173 {LOC_RESERVED(7) , "RESERVED", "", false},
174 {LOC_RESERVED(8) , "RESERVED", "", false},
175 {LOC_RESERVED(9) , "RESERVED", "", false},
177 {NID_MEDIA, "NID_MEDIA", "Tizen::Media", true},
178 {MEDIA_RESERVED(1) , "RESERVED", "", false},
179 {MEDIA_RESERVED(2) , "RESERVED", "", false},
180 {MEDIA_RESERVED(3) , "RESERVED", "", false},
181 {MEDIA_RESERVED(4) , "RESERVED", "", false},
182 {MEDIA_RESERVED(5) , "RESERVED", "", false},
183 {MEDIA_RESERVED(6) , "RESERVED", "", false},
184 {MEDIA_RESERVED(7) , "RESERVED", "", false},
185 {MEDIA_RESERVED(8) , "RESERVED", "", false},
186 {MEDIA_RESERVED(9) , "RESERVED", "", false},
188 {NID_MSG, "NID_MSG", "Tizen::Messaging", true},
189 {MSG_RESERVED(1) , "RESERVED", "", false},
190 {MSG_RESERVED(2) , "RESERVED", "", false},
191 {MSG_RESERVED(3) , "RESERVED", "", false},
192 {MSG_RESERVED(4) , "RESERVED", "", false},
193 {MSG_RESERVED(5) , "RESERVED", "", false},
194 {MSG_RESERVED(6) , "RESERVED", "", false},
195 {MSG_RESERVED(7) , "RESERVED", "", false},
196 {MSG_RESERVED(8) , "RESERVED", "", false},
197 {MSG_RESERVED(9) , "RESERVED", "", false},
199 {NID_NET, "NID_NET", "Tizen::Net", true},
200 {NID_NET_BT, "NID_NET_BT", "Tizen::Net::Bluetooth", true},
201 {NID_NET_HTTP, "NID_NET_HTTP", "Tizen::Net::Http", true},
202 {NID_NET_NFC, "NID_NET_NFC", "Tizen::Net::Nfc", true},
203 {NID_NET_SOCK, "NID_NET_SOCK", "Tizen::Net::Sockets", true},
204 {NID_NET_WIFI, "NID_NET_WIFI", "Tizen::Net::Wifi", true},
205 {NET_RESERVED(6) , "RESERVED", "", false},
206 {NET_RESERVED(7) , "RESERVED", "", false},
207 {NET_RESERVED(8) , "RESERVED", "", false},
208 {NET_RESERVED(9) , "RESERVED", "", false},
210 {NID_SEC, "NID_SEC", "Tizen::Security", true},
211 {NID_SEC_CERT, "NID_SEC_CERT", "Tizen::Security::Cert", true},
212 {NID_SEC_CRYPTO, "NID_SEC_CRYPTO", "Tizen::Security::Crypto", true},
213 {SEC_RESERVED(3) , "RESERVED", "", false},
214 {SEC_RESERVED(4) , "RESERVED", "", false},
215 {SEC_RESERVED(5) , "RESERVED", "", false},
216 {SEC_RESERVED(6) , "RESERVED", "", false},
217 {SEC_RESERVED(7) , "RESERVED", "", false},
218 {SEC_RESERVED(8) , "RESERVED", "", false},
219 {SEC_RESERVED(9) , "RESERVED", "", false},
221 {NID_SCL, "NID_SCL", "Tizen::Social", true},
222 {SCL_RESERVED(1) , "RESERVED", "", false},
223 {SCL_RESERVED(2) , "RESERVED", "", false},
224 {SCL_RESERVED(3) , "RESERVED", "", false},
225 {SCL_RESERVED(4) , "RESERVED", "", false},
226 {SCL_RESERVED(5) , "RESERVED", "", false},
227 {SCL_RESERVED(6) , "RESERVED", "", false},
228 {SCL_RESERVED(7) , "RESERVED", "", false},
229 {SCL_RESERVED(8) , "RESERVED", "", false},
230 {SCL_RESERVED(9) , "RESERVED", "", false},
232 {NID_SYS, "NID_SYS", "Tizen::System", true},
233 {SYS_RESERVED(1) , "RESERVED", "", false},
234 {SYS_RESERVED(2) , "RESERVED", "", false},
235 {SYS_RESERVED(3) , "RESERVED", "", false},
236 {SYS_RESERVED(4) , "RESERVED", "", false},
237 {SYS_RESERVED(5) , "RESERVED", "", false},
238 {SYS_RESERVED(6) , "RESERVED", "", false},
239 {SYS_RESERVED(7) , "RESERVED", "", false},
240 {SYS_RESERVED(8) , "RESERVED", "", false},
241 {SYS_RESERVED(9) , "RESERVED", "", false},
243 {NID_TEL, "NID_TEL", "Tizen::Telephony", true},
244 {TEL_RESERVED(1) , "RESERVED", "", false},
245 {TEL_RESERVED(2) , "RESERVED", "", false},
246 {TEL_RESERVED(3) , "RESERVED", "", false},
247 {TEL_RESERVED(4) , "RESERVED", "", false},
248 {TEL_RESERVED(5) , "RESERVED", "", false},
249 {TEL_RESERVED(6) , "RESERVED", "", false},
250 {TEL_RESERVED(7) , "RESERVED", "", false},
251 {TEL_RESERVED(8) , "RESERVED", "", false},
252 {TEL_RESERVED(9) , "RESERVED", "", false},
254 {NID_TEXT, "NID_TEXT", "Tizen::Text", true},
255 {TEXT_RESERVED(1) , "RESERVED", "", false},
256 {TEXT_RESERVED(2) , "RESERVED", "", false},
257 {TEXT_RESERVED(3) , "RESERVED", "", false},
258 {TEXT_RESERVED(4) , "RESERVED", "", false},
259 {TEXT_RESERVED(5) , "RESERVED", "", false},
260 {TEXT_RESERVED(6) , "RESERVED", "", false},
261 {TEXT_RESERVED(7) , "RESERVED", "", false},
262 {TEXT_RESERVED(8) , "RESERVED", "", false},
263 {TEXT_RESERVED(9) , "RESERVED", "", false},
265 {NID_UI, "NID_UI", "Tizen::Ui", true},
266 {NID_UI_ANIM, "NID_UI_ANIM", "Tizen::Ui::Animations", true},
267 {NID_UI_CTRL, "NID_UI_CTRL", "Tizen::Ui::Controls", true},
268 {NID_UI_EFFECT, "NID_UI_EFFECT", "Tizen::Ui::Effects", true},
269 {NID_UI_IME, "NID_UI_IME", "Tizen::Ui::Ime", true},
270 {NID_UI_SCENES, "NID_UI_SCENES", "Tizen::Ui::Scenes", true},
271 {UI_RESERVED(6) , "RESERVED", "", false},
272 {UI_RESERVED(7) , "RESERVED", "", false},
273 {UI_RESERVED(8) , "RESERVED", "", false},
274 {UI_RESERVED(9) , "RESERVED", "", false},
276 {NID_UIX, "NID_UIX", "Tizen::Uix", true},
277 {NID_UIX_SPEECH, "NID_UIX_SPEECH", "Tizen::Uix::Speech", true},
278 {UIX_RESERVED(2) , "RESERVED", "", false},
279 {UIX_RESERVED(3) , "RESERVED", "", false},
280 {UIX_RESERVED(4) , "RESERVED", "", false},
281 {UIX_RESERVED(5) , "RESERVED", "", false},
282 {UIX_RESERVED(6) , "RESERVED", "", false},
283 {UIX_RESERVED(7) , "RESERVED", "", false},
284 {UIX_RESERVED(8) , "RESERVED", "", false},
285 {UIX_RESERVED(9) , "RESERVED", "", false},
287 {NID_WEB, "NID_WEB", "Tizen::Web", true},
288 {NID_WEB_CTRL, "NID_WEB_CTRL", "Tizen::Web::Controls", true},
289 {NID_WEB_JSON, "NID_WEB_JSON", "Tizen::Web::Json", true},
290 {WEB_RESERVED(3) , "RESERVED", "", false},
291 {WEB_RESERVED(4) , "RESERVED", "", false},
292 {WEB_RESERVED(5) , "RESERVED", "", false},
293 {WEB_RESERVED(6) , "RESERVED", "", false},
294 {WEB_RESERVED(7) , "RESERVED", "", false},
295 {WEB_RESERVED(8) , "RESERVED", "", false},
296 {WEB_RESERVED(9) , "RESERVED", "", false},
298 {NID_SHELL, "NID_SHELL", "Tizen::Shell", true},
299 {SHELL_RESERVED(1) , "RESERVED", "", false},
300 {SHELL_RESERVED(2) , "RESERVED", "", false},
301 {SHELL_RESERVED(3) , "RESERVED", "", false},
302 {SHELL_RESERVED(4) , "RESERVED", "", false},
303 {SHELL_RESERVED(5) , "RESERVED", "", false},
304 {SHELL_RESERVED(6) , "RESERVED", "", false},
305 {SHELL_RESERVED(7) , "RESERVED", "", false},
306 {SHELL_RESERVED(8) , "RESERVED", "", false},
307 {SHELL_RESERVED(9) , "RESERVED", "", false}
311 // Other properties ===========================================================
315 true, //platformInfoEnabled;
316 true, //platformExceptionEnabled;
318 true, // applicationInfoEnabled
319 true, // applicationDebugEnabled
320 true, // applicationExceptionEnabled
325 AppLogInternal(const char* pFunction, int lineNumber, const char* pFormat, ...)
329 if (!logInfo.applicationInfoEnabled)
334 va_start(args, pFormat);
336 __PrintLog(static_cast<_LogType>(LOG_INFO), pFunction, lineNumber, pFormat, args);
342 AppLogTagInternal(const char* pTag, const char* pFunction, int lineNumber, const char* pFormat, ...)
346 if (!logInfo.applicationInfoEnabled)
351 va_start(args, pFormat);
353 __PrintLogTag(pTag, static_cast<_LogType>(LOG_INFO), pFunction, lineNumber, pFormat, args);
359 AppLogDebugInternal(const char* pFunction, int lineNumber, const char* pFormat, ...)
363 if (!logInfo.applicationDebugEnabled)
368 va_start(args, pFormat);
370 __PrintLog(static_cast<_LogType>(LOG_DEBUG), pFunction, lineNumber, pFormat, args);
376 AppLogDebugTagInternal(const char* pTag, const char* pFunction, int lineNumber, const char* pFormat, ...)
380 if (!logInfo.applicationDebugEnabled)
385 va_start(args, pFormat);
387 __PrintLogTag(pTag, static_cast<_LogType>(LOG_DEBUG), pFunction, lineNumber, pFormat, args);
393 AppLogExceptionInternal(const char* pFunction, int lineNumber, const char* pFormat, ...)
397 if (!logInfo.applicationExceptionEnabled)
402 va_start(args, pFormat);
404 __PrintLog(static_cast<_LogType>(LOG_EXCEPTION), pFunction, lineNumber, pFormat, args);
410 AppLogExceptionTagInternal(const char* pTag, const char* pFunction, int lineNumber, const char* pFormat, ...)
414 if (!logInfo.applicationExceptionEnabled)
419 va_start(args, pFormat);
421 __PrintLogTag(pTag, static_cast<_LogType>(LOG_EXCEPTION), pFunction, lineNumber, pFormat, args);
427 AppassertInternal(const char* pFunction, int lineNumber)
429 char logBody[LOG_LEN_MAX];
432 char logTag[LOG_MODULE_NAME_LEN_MAX];
434 vconf_get_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &appDebug);
435 platformDebug = File::IsFileExist( "/opt/etc/.debugmode");
437 snprintf(logTag, LOG_MODULE_NAME_LEN_MAX, "%s", appName);
438 logTag[LOG_MODULE_NAME_LEN_MAX - 1] = '\0';
440 if( (platformDebug == false) && (appDebug == 0) )
442 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > App assertion passed due to debug mode off!", pFunction, lineNumber);
443 ALOG(LOG_ERROR, logTag, logBody);
447 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > AppAssert!", pFunction, lineNumber);
448 ALOG(LOG_ERROR, logTag, logBody);
454 AppassertfInternal(const char* expr, const char* pFunction, int lineNumber, const char* pFormat, ...)
456 char logBody[LOG_LEN_MAX];
460 va_start(args, pFormat);
462 vconf_get_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &appDebug);
463 platformDebug = File::IsFileExist( "/opt/etc/.debugmode");
465 if( (platformDebug == false) && (appDebug == 0) )
467 snprintf(logBody, LOG_LEN_MAX, "App assertion passed due to debug mode off! : %s", pFormat);
468 __PrintLog(static_cast<_LogType>(LOG_USER), pFunction, lineNumber, logBody, args);
473 __PrintLog(static_cast<_LogType>(LOG_USER), pFunction, lineNumber, pFormat, args);
482 SysLogInternal(unsigned long nid, const char* pFunction, int lineNumber, const char* pFormat, ...)
485 char* envValuePlatformlogging;
490 envValuePlatformlogging = getenv("TIZEN_PLATFORMLOGGING_MODE");
491 envValueDebug = getenv("TIZEN_DEBUG_MODE");
493 if ((envValuePlatformlogging != NULL) && (envValuePlatformlogging[0] == '1'))
495 envPlatformInfoEnabled = true;
497 else if ((envValueDebug != NULL) && (envValueDebug[0] == '1'))
499 envPlatformInfoEnabled = true;
503 envPlatformInfoEnabled = false;
508 if (!envPlatformInfoEnabled)
513 if (!logInfo.platformInfoEnabled)
518 va_start(args, pFormat);
520 __PrintSysLog(static_cast<_LogType>(LOG_INFO), static_cast<LogID>(nid), pFunction, lineNumber, pFormat, args);
526 SysLogExceptionInternal(unsigned long nid, result r, const char* pFunction, int lineNumber, const char* pFormat, ...)
532 if (!logInfo.platformExceptionEnabled)
537 va_start(args, pFormat);
539 __PrintSysLog(static_cast<_LogType>(LOG_EXCEPTION), static_cast<LogID>(nid), pFunction, lineNumber, pFormat, args);
545 SysLogTagInternal(unsigned long nid, const char* pTag, const char* pFunction, int lineNumber, const char* pFormat, ...)
548 char* envValuePlatformlogging;
553 envValuePlatformlogging = getenv("TIZEN_PLATFORMLOGGING_MODE");
554 envValueDebug = getenv("TIZEN_DEBUG_MODE");
556 if ((envValuePlatformlogging != NULL) && (envValuePlatformlogging[0] == '1'))
558 envPlatformInfoEnabled = true;
560 else if ((envValueDebug != NULL) && (envValueDebug[0] == '1'))
562 envPlatformInfoEnabled = true;
566 envPlatformInfoEnabled = false;
571 if (!envPlatformInfoEnabled)
576 if (!logInfo.platformInfoEnabled)
581 va_start(args, pFormat);
583 __PrintSysLogTag(pTag, static_cast<_LogType>(LOG_INFO), static_cast<LogID>(nid), pFunction, lineNumber, pFormat, args);
589 SysLogExceptionTagInternal(unsigned long nid, const char* pTag, result r, const char* pFunction, int lineNumber,
597 if (!logInfo.platformExceptionEnabled)
602 va_start(args, pFormat);
604 __PrintSysLogTag(pTag, static_cast<_LogType>(LOG_EXCEPTION), static_cast<LogID>(nid), pFunction, lineNumber, pFormat, args);
611 SysAssertInternal(const char* pFileName, int lineNumber, const char* pFunction)
615 char logBody[LOG_LEN_MAX];
617 platformDebug = File::IsFileExist( "/opt/etc/.debugmode");
624 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > SysAssert!", pFunction, lineNumber);
626 ALOG(LOG_ERROR, LOG_TAG_ASSERT, logBody);
632 SysAssertfInternal(const char* expr, const char* pFunction, int lineNumber, const char* pFormat, ...)
634 char logBody[LOG_LEN_MAX];
638 platformDebug = File::IsFileExist( "/opt/etc/.debugmode");
645 va_start(args, pFormat);
647 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
648 logBody[LOG_LEN_MAX - 1] = '\0';
650 ALOG_VA(LOG_ERROR, LOG_TAG_ASSERT, logBody, args);
658 SysPropagateInternal(const char* pFunction, int lineNumber, unsigned long nid, result r)
660 char logBody[PROPAGATION_LEN_MAX];
661 snprintf(logBody, PROPAGATION_LEN_MAX, "%s(%d) > [%s] Propagating to caller...", pFunction, lineNumber, GetErrorMessage(r));
663 char logTag[LOG_MODULE_NAME_LEN_MAX];
664 snprintf(logTag, LOG_MODULE_NAME_LEN_MAX, "%s", __GetModuleName(static_cast<LogID>(nid)));
666 ALOG(LOG_ERROR, logTag, logBody);
670 SysTryReturnResultInternal(unsigned long id, result r, const char* pFunction, int lineNumber, const char* pFormat, ...)
677 if (!logInfo.platformExceptionEnabled)
684 __InitializeLogInfo();
687 if (!__GetEnableInfo(static_cast<LogID>(id)))
692 va_start(args, pFormat);
694 char logBody[LOG_LEN_MAX];
695 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > [%s] %s", pFunction, lineNumber, GetErrorMessage(r), pFormat);
696 logBody[LOG_LEN_MAX -1] = '\0';
698 char logTag[LOG_MODULE_NAME_LEN_MAX];
700 snprintf(logTag, LOG_MODULE_NAME_LEN_MAX, "%s", __GetModuleName(static_cast<LogID>(id)));
701 logTag[LOG_MODULE_NAME_LEN_MAX - 1] = '\0';
703 ALOG_VA(LOG_ERROR, logTag, logBody, args);
711 __PrintLog(_LogType type, const char* pFunction, int lineNumber, const char* pFormat, va_list args)
715 __InitializeLogInfo();
718 char logBody[LOG_LEN_MAX];
719 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
720 logBody[LOG_LEN_MAX - 1] = '\0';
722 char logTag[LOG_MODULE_NAME_LEN_MAX];
726 appNameLoaded = true;
727 char* pAppName = _StringConverter::CopyToCharArrayN(_AppInfo::GetAppExecutableName());
728 strncpy(appName, pAppName, LOG_MODULE_NAME_LEN_MAX);
731 snprintf(logTag, LOG_MODULE_NAME_LEN_MAX, "%s", appName);
733 logTag[LOG_MODULE_NAME_LEN_MAX - 1] = '\0';
737 case static_cast<_LogType>(LOG_INFO):
738 ALOG_VA(LOG_INFO, logTag, logBody, args);
741 case static_cast<_LogType>(LOG_DEBUG):
742 ALOG_VA(LOG_DEBUG, logTag, logBody, args);
745 case static_cast<_LogType>(LOG_EXCEPTION):
746 ALOG_VA(LOG_ERROR, logTag, logBody, args);
749 case static_cast<_LogType>(LOG_USER):
750 ALOG_VA(LOG_ERROR, logTag, logBody, args);
754 ALOG_VA(LOG_DEBUG, LOG_TAG_NULL, logBody, args);
760 __PrintLogTag(const char* pTag, _LogType type, const char* pFunction, int lineNumber, const char* pFormat, va_list args)
764 __InitializeLogInfo();
767 char logBody[LOG_LEN_MAX];
768 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
769 logBody[LOG_LEN_MAX -1] = '\0';
771 char logTag[LOG_TAG_LEN_MAX];
773 snprintf(logTag, LOG_TAG_LEN_MAX, "%s", pTag);
774 logTag[LOG_TAG_LEN_MAX - 1] = '\0';
778 case static_cast<_LogType>(LOG_INFO):
779 ALOG_VA(LOG_INFO, logTag, logBody, args);
782 case static_cast<_LogType>(LOG_DEBUG):
783 ALOG_VA(LOG_DEBUG, logTag, logBody, args);
786 case static_cast<_LogType>(LOG_EXCEPTION):
787 ALOG_VA(LOG_ERROR, logTag, logBody, args);
790 case static_cast<_LogType>(LOG_USER):
791 ALOG_VA(LOG_ERROR, logTag, logBody, args);
795 ALOG_VA(LOG_DEBUG, LOG_TAG_NULL, logBody, args);
802 __PrintSysLog(_LogType type, LogID id, const char* pFunction, int lineNumber, const char* pFormat, va_list args)
806 __InitializeLogInfo();
809 if (!__GetEnableInfo(static_cast<LogID>(id)))
814 char logBody[LOG_LEN_MAX];
815 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
816 logBody[LOG_LEN_MAX -1] = '\0';
818 char logTag[LOG_MODULE_NAME_LEN_MAX];
820 snprintf(logTag, LOG_MODULE_NAME_LEN_MAX, "%s", __GetModuleName(static_cast<LogID>(id)));
821 logTag[LOG_MODULE_NAME_LEN_MAX - 1] = '\0';
825 case static_cast<_LogType>(LOG_INFO):
826 LOG_VA(LOG_INFO, logTag, logBody, args);
829 case static_cast<_LogType>(LOG_DEBUG):
830 LOG_VA(LOG_DEBUG, logTag, logBody, args);
833 case static_cast<_LogType>(LOG_EXCEPTION):
834 ALOG_VA(LOG_ERROR, logTag, logBody, args);
837 case static_cast<_LogType>(LOG_USER):
838 ALOG_VA(LOG_ERROR, logTag, logBody, args);
842 LOG_VA(LOG_DEBUG, LOG_TAG_NULL, logBody, args);
848 __PrintSysLogTag(const char* pTag, _LogType type, LogID id, const char* pFunction, int lineNumber, const char* pFormat, va_list args)
852 __InitializeLogInfo();
855 if (!__GetEnableInfo(static_cast<LogID>(id)))
860 char logBody[LOG_LEN_MAX];
861 snprintf(logBody, LOG_LEN_MAX, "%s(%d) > %s", pFunction, lineNumber, pFormat);
862 logBody[LOG_LEN_MAX -1] = '\0';
864 char logTag[LOG_MODULE_NAME_LEN_MAX + LOG_TAG_LEN_MAX];
866 snprintf(logTag, LOG_MODULE_NAME_LEN_MAX + LOG_TAG_LEN_MAX, "%s | %s", __GetModuleName(static_cast<LogID>(id)), pTag);
867 logTag[LOG_MODULE_NAME_LEN_MAX + LOG_TAG_LEN_MAX - 1] = '\0';
871 case static_cast<_LogType>(LOG_INFO):
872 LOG_VA(LOG_INFO, logTag, logBody, args);
875 case static_cast<_LogType>(LOG_DEBUG):
876 LOG_VA(LOG_DEBUG, logTag, logBody, args);
879 case static_cast<_LogType>(LOG_EXCEPTION):
880 ALOG_VA(LOG_ERROR, logTag, logBody, args);
883 case static_cast<_LogType>(LOG_USER):
884 ALOG_VA(LOG_ERROR, logTag, logBody, args);
888 LOG_VA(LOG_DEBUG, LOG_TAG_NULL, logBody, args);
894 __GetModuleName(LogID id)
896 return logInfo.logTable[id].logModuleName;
900 __GetEnableInfo(LogID id)
902 return logInfo.logTable[id].loggingEnabled;
906 __InitializeLogInfo()
912 const String regPath(L"/opt/usr/etc/system-log.ini");
916 r = reg.Construct(regPath, REG_OPEN_READ_ONLY, 0);
920 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] opening ini file failed.\n");
924 __InitializeLogLevel(reg);
925 __InitializePlatformModule(reg);
929 __InitializeLogLevel(const Registry& reg)
931 String sectApp(L"Application");
932 String sectPlatform(L"Platform");
934 String entryInfo(L"INFO");
935 String entryDebug(L"DEBUG");
936 String entryException(L"EXCEPTION");
938 String strYes(L"YES");
943 r = reg.GetValue(sectApp, entryInfo, retString);
946 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Application/INFO failed.\n");
949 logInfo.applicationInfoEnabled = retString.Equals(strYes);
952 r = reg.GetValue(sectApp, entryDebug, retString);
955 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Application/DEBUG failed.\n");
958 logInfo.applicationDebugEnabled = retString.Equals(strYes);
961 r = reg.GetValue(sectApp, entryException, retString);
964 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Application/EXCEPTION failed.\n");
967 logInfo.applicationExceptionEnabled = retString.Equals(strYes);
970 r = reg.GetValue(sectPlatform, entryInfo, retString);
973 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Platform/INFO failed.\n");
976 logInfo.platformInfoEnabled = retString.Equals(strYes);
979 r = reg.GetValue(sectPlatform, entryException, retString);
982 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding Platform/EXCEPTION failed.\n");
985 logInfo.platformExceptionEnabled = retString.Equals(strYes);
990 __InitializePlatformModule(const Registry& reg)
992 String strYes(L"YES");
995 String sectModule(L"PlatformModules");
999 for (int i = 0; i < NID_MAX; i++)
1001 String strEntry(logInfo.logTable[i].logIDName);
1002 r = reg.GetValue(sectModule, strEntry, retString);
1005 ALOG(LOG_ERROR, LOG_TAG, "[EXCEPTION] finding PlatformModules/%ls failed.\n", strEntry.GetPointer());
1009 logInfo.logTable[i].loggingEnabled = retString.Equals(strYes);