summaryrefslogtreecommitdiff
path: root/src/logger.c
blob: 14bc5c88b6efcb6231d81795d92e93a8ddba59d4 (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
#include "logger.h"
#include "config.h"

unsigned int zlog_env_is_init = 0;

void logger_init()
{
    const struct config * conf = global_config_get();

    int ret = dzlog_init(conf->zlog_config_path, "default_zlog_category");
    if (ret != 0)
    {
        char * zlog_profile_error = getenv("ZLOG_PROFILE_ERROR");
        printf("fail in dzlog_int.\n");
        if (zlog_profile_error != NULL)
        {
            printf("The dzlog_init function error infomation is recorded in:%s\n", zlog_profile_error);
        }
        exit(EXIT_FAILURE);
    }
    zlog_env_is_init = 1;

    ret = zlog_init(conf->zlog_config_path);
    DP_TRACE_VERIFY(ret != 0, "zlog init failed.");
}

zlog_category_t * kafka_dump_logger_get()
{
    const struct config * conf = global_config_get();

    if (conf->kafka_dump_to_log)
    {
        zlog_category_t * logger = zlog_get_category("kafka_dump");
        DP_TRACE_VERIFY(logger != NULL, "kafka_dump logger is null.");
        return logger;
    }

    return NULL;
}