47 lines
1.7 KiB
C
47 lines
1.7 KiB
C
//TODO: 日志打印出文件名 + 行号
|
|
|
|
|
|
#pragma once
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <assert.h>
|
|
#include <pthread.h>
|
|
#include <unistd.h>
|
|
#include <arpa/inet.h>
|
|
#include <time.h>
|
|
#include "MESA/MESA_handle_logger.h"
|
|
#include "MESA/MESA_htable.h"
|
|
#include "MESA/MESA_prof_load.h"
|
|
#include "field_stat2.h"
|
|
#include "Maat_rule.h"
|
|
#include "Maat_command.h"
|
|
|
|
#define KNI_STRING_MAX 2048
|
|
#define KNI_PATH_MAX 256
|
|
#define KNI_SYMBOL_MAX 64
|
|
#define likely(expr) __builtin_expect((expr), 1)
|
|
#define unlikely(expr) __builtin_expect((expr), 0)
|
|
|
|
#define ALLOC(type, number) ((type *)calloc(sizeof(type), number))
|
|
#define FREE(p) {free(*p);*p=NULL;}
|
|
|
|
#define KNI_LOG_ERROR(handler, fmt, ...) \
|
|
do { \
|
|
char location[KNI_PATH_MAX]; \
|
|
snprintf(location, KNI_PATH_MAX, "%s: line %d", __FILE__, __LINE__); \
|
|
MESA_handle_runtime_log(handler, RLOG_LV_FATAL, location, fmt, ##__VA_ARGS__); } while(0)
|
|
|
|
#define KNI_LOG_INFO(handler, fmt, ...) \
|
|
do { \
|
|
char location[KNI_PATH_MAX]; \
|
|
snprintf(location, KNI_PATH_MAX, "%s: line %d", __FILE__, __LINE__); \
|
|
MESA_handle_runtime_log(handler, RLOG_LV_INFO, location, fmt, ##__VA_ARGS__); } while(0)
|
|
|
|
#define KNI_LOG_DEBUG(handler, fmt, ...) \
|
|
do { \
|
|
char location[KNI_PATH_MAX]; \
|
|
snprintf(location, KNI_PATH_MAX, "%s: line %d", __FILE__, __LINE__); \
|
|
MESA_handle_runtime_log(handler, RLOG_LV_DEBUG, location, fmt, ##__VA_ARGS__); } while(0)
|
|
|
|
//fprintf(stderr, fmt "\n", ##__VA_ARGS__);
|
|
MESA_htable_handle KNI_utils_create_htable(const char *profile, const char *section, void *free_data_cb, void *expire_notify_cb, void *logger); |