summaryrefslogtreecommitdiff
path: root/src/components/syslogd/logging.c
blob: fc80e68f936ad5637d79f1276b60c908348485d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*************************************************************************
	> 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"

void mesa_logging_print(int log_level, char *module, char *msg)
{
    MESA_handle_runtime_log(logging_sc_lid.run_log_handle, log_level, module, msg);
    return;
}

void cert_syslog_init(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;
}