29 lines
1.1 KiB
C
29 lines
1.1 KiB
C
|
#ifndef _KLOG_API_H
|
||
|
#define _KLOG_API_H
|
||
|
|
||
|
#include <linux/kernel.h>
|
||
|
#include "common_types.h"
|
||
|
|
||
|
#define MAX_MODULE_NAME_SZ 16
|
||
|
|
||
|
typedef struct _klog {
|
||
|
char module_name[MAX_MODULE_NAME_SZ];
|
||
|
}klog_t;
|
||
|
|
||
|
|
||
|
extern klog_t *klog_init(const char *module_name);
|
||
|
extern void klog_close(klog_t *log);
|
||
|
extern void klog_record(const klog_t *log, const char* level_str, const char *fmt, ...);
|
||
|
|
||
|
#define KLOG_DEBUG(log, fmt, ...) klog_record(log, KERN_DEBUG, fmt, ##__VA_ARGS__)
|
||
|
#define KLOG_INFO(log, fmt, ...) klog_record(log, KERN_INFO, fmt, ##__VA_ARGS__)
|
||
|
#define KLOG_NOTICE(log, fmt, ...) klog_record(log, KERN_NOTICE, fmt, ##__VA_ARGS__)
|
||
|
#define KLOG_WARNING(log, fmt, ...) klog_record(log, KERN_WARNING, fmt, ##__VA_ARGS__)
|
||
|
#define KLOG_ERR(log, fmt, ...) klog_record(log, KERN_ERR, fmt, ##__VA_ARGS__)
|
||
|
#define KLOG_CRIT(log, fmt, ...) klog_record(log, KERN_CRIT, fmt, ##__VA_ARGS__)
|
||
|
#define KLOG_ALERT(log, fmt, ...) klog_record(log, KERN_ALERT, fmt, ##__VA_ARGS__)
|
||
|
#define KLOG_EMERG(log, fmt, ...) klog_record(log, KERN_EMERG, fmt, ##__VA_ARGS__)
|
||
|
|
||
|
#endif
|
||
|
|