[Feature][T108] [task-view-1792] Optimize the HAL log interface

Only Configure: No
Affected branch: GSW_V1453
Affected module: log
Self-test: yes
Doc Update: no

Change-Id: I6ad873a6c4351de9d1d7d6b09fec8ec9ce08841e
diff --git a/mbtk/libgsw_lib/gsw_log_interface.c b/mbtk/libgsw_lib/gsw_log_interface.c
new file mode 100755
index 0000000..ae51b01
--- /dev/null
+++ b/mbtk/libgsw_lib/gsw_log_interface.c
@@ -0,0 +1,29 @@
+#include "gsw_log_interface.h"
+
+void *handle = NULL;
+int log_initialized = 0;
+mbtk_log gsw_fun_ptr_log;
+int init_log_func(void)
+{
+    if (log_initialized)
+        return 0;
+
+    handle = dlopen("/lib/libmbtk_lib.so", RTLD_NOW);
+    if (!handle)
+        {
+        syslog(LOG_ERR, "Failed to load library: %s", dlerror());
+        return -1;
+    }
+
+    gsw_fun_ptr_log = (mbtk_log)dlsym(handle, "mbtk_log");
+    if (!gsw_fun_ptr_log)
+        {
+        syslog(LOG_ERR, "Cannot load symbol 'mbtk_log': %s", dlerror());
+        dlclose(handle);
+        handle = NULL;
+        return -1;
+    }
+
+    log_initialized = 1;
+    return 0;
+}