00001
00002
00003
00004
00005
00006
00007 #ifndef _NMF_LOG
00008 #define _NMF_LOG
00009 #include <stdio.h>
00010 #include <stdarg.h>
00011
00012 #ifdef __cplusplus
00013 extern "C" {
00014 #endif
00015
00016 #define NMF_LOG_ERR 1
00017 #define NMF_LOG_WARN 2
00018 #define NMF_LOG_INFO 3
00019 #define NMF_LOG_DEBUG 4
00020 static char *log_pfx[] = {
00021 [0] = "NMF Bad Log Level",
00022 [NMF_LOG_ERR] = "NMF ERROR: ",
00023 [NMF_LOG_WARN] = "NMF WARNING: ",
00024 [NMF_LOG_INFO] = "NMF INFO: ",
00025 [NMF_LOG_DEBUG] = "NMF DEBUG: "
00026 };
00027
00028 static char log_format[256];
00029 static inline void nmf_log(int level, char *format, ...)
00030 {
00031 extern int __nmf_log_level;
00032 va_list ap;
00033 va_start(ap, format);
00034 if (level > __nmf_log_level)
00035 return;
00036 log_format[0] = 0;
00037 strcat(log_format, log_pfx[(level>NMF_LOG_DEBUG?0:level)]);
00038 strcat(log_format, format);
00039 vfprintf(stderr, log_format, ap);
00040 }
00041
00042 #ifdef __cplusplus
00043 }
00044 #endif
00045
00046 #endif