removed locking from the dump functions, at error/report time we already have the...
[nobug.git] / nobug.c
blob17716c0164d95749e0ddd94f122e0c7901cb925d
1 /*
2 nobug.c - a small debugging library
4 Copyright (C) 2007, Christian Thaeter <ct@pipapo.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, contact me.
20 #include <pthread.h>
22 #define NOBUG_LIBNOBUG_C
23 #include "nobug.h"
26 struct nobug_ringbuffer* nobug_default_ringbuffer = NULL;
27 static struct nobug_ringbuffer nobug_default_ringbuffer_real;
28 FILE* nobug_default_file = NULL;
30 struct nobug_flag nobug_flag_NOBUG_ON =
31 {NULL, {LOG_DEBUG, LOG_DEBUG, LOG_DEBUG, LOG_DEBUG, LOG_DEBUG}, NULL,NULL,NULL};
33 static int nobug_initialized = 0;
37 default initialization
39 void
40 nobug_init()
42 if (nobug_initialized)
43 return;
45 nobug_initialized = 1;
47 #if NOBUG_USE_PTHREAD
48 pthread_key_create (&nobug_thread_id_key, free);
49 #endif
51 /* we initialize a minimal ringbuffer */
52 if (!nobug_default_ringbuffer)
54 nobug_default_ringbuffer = &nobug_default_ringbuffer_real;
55 nobug_ringbuffer_init (nobug_default_ringbuffer, 4096, NULL, NOBUG_RINGBUFFER_DEFAULT);
58 /* initialize the always-on flag*/
59 nobug_flag_NOBUG_ON.ringbuffer_target = nobug_default_ringbuffer;
60 nobug_flag_NOBUG_ON.console_target = stderr;
61 nobug_flag_NOBUG_ON.file_target = nobug_default_file;