summaryrefslogtreecommitdiffstats
path: root/src/framework
diff options
context:
space:
mode:
authoryalei wang <wylandrea@gmail.com>2018-08-27 02:21:37 +0000
committerGerrit Code Review <gerrit@fd.io>2018-08-27 02:21:37 +0000
commit0c28fb6fca575d1cc8463725b8cd594a188c221a (patch)
tree4ff86b71346822c8503d19dead5a50d22673f2d1 /src/framework
parent496c79e387313825c37b303b1c9fc123e34e6165 (diff)
parent1414b5a0ce42358c54bf5b68f9228fe21f815efc (diff)
Merge "Fix: Fix the app's log name"
Diffstat (limited to 'src/framework')
-rw-r--r--src/framework/log/nstack_log.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/framework/log/nstack_log.c b/src/framework/log/nstack_log.c
index 5e62ad7..6678996 100644
--- a/src/framework/log/nstack_log.c
+++ b/src/framework/log/nstack_log.c
@@ -576,6 +576,31 @@ app_default:
}
/*****************************************************************************
+* Prototype : nstack_get_app_logname
+* Description : get the name of app's log
+* Input : None
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*****************************************************************************/
+int
+nstack_get_app_logname (char* log_name)
+{
+ int pid = getpid ();
+ char processname[FILE_NAME_LEN] = {0};
+
+ if (log_name == NULL)
+ return 1;
+
+ strncpy (processname, program_invocation_short_name, 10);
+
+ snprintf (log_name, FILE_NAME_LEN, "app_%s_%d.log", processname, pid);
+
+ return 0;
+}
+
+/*****************************************************************************
* Prototype : nstack_log_init_app
* Description : called by environment-specific log init function
* Input : None
@@ -592,6 +617,8 @@ nstack_log_init_app ()
int i = 0;
int file_flag = 0;
char app_log_path[FILE_NAME_LEN] = { 0 };
+ int ret = 0;
+ char app_log_name[FILE_NAME_LEN] = { 0 };
/* log already initialized, just return */
if (LOG_PRO_INVALID != g_my_pro_type)
@@ -661,7 +688,15 @@ nstack_log_init_app ()
glogSetLogSymlink (i, "");
nstack_log_count_set (APP_LOG_COUNT);
glogMaxLogSizeSet (APP_LOG_SIZE);
- glogSetLogFilenameExtension (APP_LOG_NAME);
+ ret = nstack_get_app_logname (app_log_name);
+ if (ret == 0)
+ {
+ glogSetLogFilenameExtension (app_log_name);
+ }
+ else
+ {
+ glogSetLogFilenameExtension (APP_LOG_NAME);
+ }
glogFlushLogSecsSet (FLUSH_TIME);
}
else