diff options
author | Le-Tin <Tin.Le@vn.bosch.com> | 2021-08-18 07:39:02 +0000 |
---|---|---|
committer | Saya Sugiura <ssugiura@jp.adit-jv.com> | 2021-10-05 11:07:38 +0900 |
commit | f16953f5ab2506ef0fb714fe6bb8a022845b8c68 (patch) | |
tree | 3202f214201ad9c6cfe3462f8753668a579cf672 | |
parent | 14ffd9576f1a1e382ed2b93c1c281941a8e3da85 (diff) | |
download | DLT-daemon-f16953f5ab2506ef0fb714fe6bb8a022845b8c68.tar.gz |
lib: generate dlt library internal log file
Extern logging_mode and logging_handle variables from commom.c
Reusing dlt_log_init() in cases dlt library internal log file is not opened and logging_mode is DLT_LOG_TO_FILE
Signed-off-by: Le-Tin <Tin.Le@vn.bosch.com>
-rw-r--r-- | src/lib/dlt_user.c | 10 | ||||
-rw-r--r-- | src/shared/dlt_common.c | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index 3d1c18c..2f54023 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -144,6 +144,10 @@ pthread_mutex_t mq_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t mq_init_condition; #endif /* DLT_NETWORK_TRACE_ENABLE */ +/* use these variables from common.c*/ +extern int logging_mode; +extern FILE *logging_handle; + void dlt_lock_mutex(pthread_mutex_t *mutex) { int32_t lock_mutex_result = pthread_mutex_lock(mutex); @@ -454,6 +458,12 @@ DltReturnValue dlt_init(void) /* check environment variables */ dlt_check_envvar(); + /* Check logging mode and internal log file is opened or not*/ + if(logging_mode == DLT_LOG_TO_FILE && logging_handle == NULL) + { + dlt_log_init(logging_mode); + } + /* process is exiting. Do not allocate new resources. */ if (dlt_user_freeing != 0) { dlt_vlog(LOG_INFO, "%s logging disabled, process is exiting", __func__); diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c index 0a122c5..de65201 100644 --- a/src/shared/dlt_common.c +++ b/src/shared/dlt_common.c @@ -77,11 +77,11 @@ char dltShmName[NAME_MAX + 1] = "/dlt-shm"; #endif /* internal logging parameters */ -static int logging_mode = DLT_LOG_TO_CONSOLE; static int logging_level = LOG_INFO; static char logging_filename[NAME_MAX + 1] = ""; -static FILE *logging_handle = NULL; static bool print_with_attributes = false; +int logging_mode = DLT_LOG_TO_CONSOLE; +FILE *logging_handle = NULL; char *message_type[] = { "log", "app_trace", "nw_trace", "control", "", "", "", "" }; char *log_info[] = { "", "fatal", "error", "warn", "info", "debug", "verbose", "", "", "", "", "", "", "", "", "" }; |