diff options
author | rainbow_0206 <jiangwenjiang@huawei.com> | 2018-07-28 17:36:49 +0800 |
---|---|---|
committer | rainbow_0206 <jiangwenjiang@huawei.com> | 2018-08-25 17:27:33 +0800 |
commit | 1414b5a0ce42358c54bf5b68f9228fe21f815efc (patch) | |
tree | a0e09f5eeebf31e843d3777f55e8331dc256aafb /src/framework | |
parent | ea6eab2f7fb9e849c719fa7374616cc1d6b736a3 (diff) |
Fix: Fix the app's log name
Change-Id: I276e770c93d1f484854d90bd49ff16cb02047e40
Signed-off-by: rainbow_0206 <jiangwenjiang@huawei.com>
Diffstat (limited to 'src/framework')
-rw-r--r-- | src/framework/log/nstack_log.c | 37 |
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 |