summaryrefslogtreecommitdiff
path: root/common/syslogd
diff options
context:
space:
mode:
Diffstat (limited to 'common/syslogd')
-rw-r--r--common/syslogd/include/logging.h51
-rw-r--r--common/syslogd/src/logging.cpp57
2 files changed, 108 insertions, 0 deletions
diff --git a/common/syslogd/include/logging.h b/common/syslogd/include/logging.h
new file mode 100644
index 0000000..8d3ac35
--- /dev/null
+++ b/common/syslogd/include/logging.h
@@ -0,0 +1,51 @@
+/*************************************************************************
+ > File Name: logging.h
+ > Author:
+ > Mail:
+ > Created Time: 2018年06月18日 星期一 22时45分58秒
+ ************************************************************************/
+
+#ifndef _LOGGING_H
+#define _LOGGING_H
+
+#define MODULE_NAME "CA"
+
+#define RLOG_LV_DEBUG 10
+#define RLOG_LV_INFO 20
+#define RLOG_LV_FATAL 30
+
+typedef struct RTLogInit2Data_ {
+ int debug_switch;
+
+ int run_log_level;
+
+ char run_log_path[256];
+
+ void *run_log_handle;
+} RTLogInit2Data;
+
+extern RTLogInit2Data logging_sc_lid;
+
+/* The maximum length of the log message */
+#define RT_LOG_MAX_LOG_MSG_LEN 2048
+
+extern void mesa_logging_print(int log_level, const char *module, const char *msg);
+
+#define mesa_log(x, y, z, ...) do { \
+ char _sc_log_msg[RT_LOG_MAX_LOG_MSG_LEN] = ""; \
+ char *_sc_log_temp = _sc_log_msg; \
+ if ( !x ) \
+ { } else { \
+ snprintf(_sc_log_temp, \
+ (RT_LOG_MAX_LOG_MSG_LEN - \
+ (_sc_log_temp - _sc_log_msg)), \
+ __VA_ARGS__); \
+ mesa_logging_print(y, z, _sc_log_msg); \
+ } \
+ } while(0)
+
+#define mesa_runtime_log(level, module, ...) mesa_log(logging_sc_lid.debug_switch, level, module, __VA_ARGS__)
+
+void cert_syslog_init(const char *config);
+
+#endif
diff --git a/common/syslogd/src/logging.cpp b/common/syslogd/src/logging.cpp
new file mode 100644
index 0000000..d85bb71
--- /dev/null
+++ b/common/syslogd/src/logging.cpp
@@ -0,0 +1,57 @@
+/*************************************************************************
+ > File Name: logging.c
+ > Author:
+ > Mail:
+ > Created Time: 2018年06月18日 星期一 22时45分43秒
+ ************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <dirent.h>
+#include <ctype.h>
+
+#include "rt_common.h"
+#include "rt_time.h"
+#include "rt_string.h"
+#include "logging.h"
+#include "MESA_prof_load.h"
+#include "MESA_handle_logger.h"
+
+RTLogInit2Data logging_sc_lid;
+
+void mesa_logging_print(int log_level, const char *module, const char *msg)
+{
+ MESA_handle_runtime_log(logging_sc_lid.run_log_handle, log_level, (const char *)module, msg);
+ return;
+}
+
+void cert_syslog_init(const char *config)
+{
+ char run_log_path[256] = {0};
+
+ MESA_load_profile_int_def(config, (const char *)"SYSTEM",(const char *)"DEBUG_SWITCH",
+ &logging_sc_lid.debug_switch, 1);
+ MESA_load_profile_int_def(config, (const char *)"SYSTEM",(const char *)"RUN_LOG_LEVEL",
+ &logging_sc_lid.run_log_level, 10);
+ MESA_load_profile_string_def(config, (const char *)"SYSTEM",(const char *)"RUN_LOG_PATH",
+ logging_sc_lid.run_log_path, 128, NULL);
+
+ snprintf(run_log_path, 255, "%s/%s", logging_sc_lid.run_log_path, "certstore.log");
+
+ logging_sc_lid.run_log_handle = MESA_create_runtime_log_handle(run_log_path, logging_sc_lid.run_log_level);
+ if(logging_sc_lid.run_log_handle == NULL){
+ mesa_runtime_log(RLOG_LV_FATAL, MODULE_NAME, "Create log runtime_log_handle error, init failed!");
+ goto finish;
+ }else{
+ mesa_runtime_log(RLOG_LV_INFO, MODULE_NAME, "Log module initialization");
+ }
+finish:
+ return;
+}
+
+