00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifdef HAVE_CONFIG_H
00027 # include <config.h>
00028 #endif
00029
00030 #include <stdio.h>
00031 #include <stdlib.h>
00032 #include <string.h>
00033 #include <stdarg.h>
00034
00035 #include "logger.h"
00036
00045 static int priority;
00046 static const char* file;
00047 static int line;
00048 static const char* function;
00049
00053 void logger_init()
00054 {
00055 }
00056
00064 void logger_setup(int _priority, const char* _file, int _line,
00065 const char* _function)
00066 {
00067 priority = _priority;
00068 file = _file;
00069 line = _line;
00070 function = _function;
00071 }
00072
00078 void logger_emit(const char* format,...)
00079 {
00080 va_list args;
00081 char buf[512];
00082 char* pri;
00083
00084 va_start(args, format);
00085 vsnprintf(buf, 512, format, args);
00086
00087 switch( priority )
00088 {
00089 case HAL_LOGPRI_TRACE: pri="[T]"; break;
00090 case HAL_LOGPRI_DEBUG: pri="[D]"; break;
00091 case HAL_LOGPRI_INFO: pri="[I]"; break;
00092 case HAL_LOGPRI_WARNING: pri="[W]"; break;
00093 default:
00094 case HAL_LOGPRI_ERROR: pri="[E]"; break;
00095 }
00096
00098 if( priority!=HAL_LOGPRI_TRACE )
00099 fprintf(stderr, "%s %s:%d %s() : %s\n",
00100 pri, file, line, function, buf);
00101
00102 va_end(args);
00103 }
00104
00105