aboutsummaryrefslogtreecommitdiffstats
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
parent496c79e387313825c37b303b1c9fc123e34e6165 (diff)
parent1414b5a0ce42358c54bf5b68f9228fe21f815efc (diff)
Merge "Fix: Fix the app's log name"
-rw-r--r--doc/DMM_DeveloperManual.md2
-rw-r--r--src/framework/log/nstack_log.c37
2 files changed, 37 insertions, 2 deletions
diff --git a/doc/DMM_DeveloperManual.md b/doc/DMM_DeveloperManual.md
index 9abca95..51e4be5 100644
--- a/doc/DMM_DeveloperManual.md
+++ b/doc/DMM_DeveloperManual.md
@@ -1042,7 +1042,7 @@ typedef enum _LOG_MODULE
#define NSLOG_OFF 0x00
```
-App logs stored in nStack_nSocket.log. Stackx logs will be stored in running.log. Other operational
+App logs stored in app_$pname_$pid.log. Stackx logs will be stored in running.log. Other operational
logs will be stored in operation.log. App logs will be stored in file if following is set to 1.
```
export NSTACK_LOG_FILE_FLAG=1
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