girara
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
debug.c
Go to the documentation of this file.
1 /* See LICENSE file for license and copyright information */
2 
3 #include "utils.h"
4 #include <stdarg.h>
5 
6 static girara_debug_level_t debug_level = GIRARA_DEBUG;
7 
8 void
9 _girara_debug(const char* function, int line, girara_debug_level_t level, const char* format, ...)
10 {
11  if (level < debug_level) {
12  return;
13  }
14 
15  switch (level)
16  {
17  case GIRARA_WARNING:
18  fprintf(stderr, "warning: ");
19  break;
20  case GIRARA_ERROR:
21  fprintf(stderr, "error: ");
22  break;
23  case GIRARA_INFO:
24  fprintf(stderr, "info: ");
25  break;
26  case GIRARA_DEBUG:
27  fprintf(stderr, "debug: (%s:%d) ", function, line);
28  break;
29  default:
30  return;
31  }
32 
33  va_list ap;
34  va_start(ap, format);
35  vfprintf(stderr, format, ap);
36  va_end(ap);
37 
38  fprintf(stderr, "\n");
39 }
40 
43 {
44  return debug_level;
45 }
46 
47 void
49 {
50  debug_level = level;
51 }
girara_debug_level_t
Definition: types.h:58
girara_debug_level_t girara_get_debug_level()
Definition: debug.c:42
void girara_set_debug_level(girara_debug_level_t level)
Definition: debug.c:48
void _girara_debug(const char *function, int line, girara_debug_level_t level, const char *format,...)
Definition: debug.c:9