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.
22 #define NOBUG_LIBNOBUG_C
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
42 if (nobug_initialized
)
45 nobug_initialized
= 1;
48 pthread_key_create (&nobug_thread_id_key
, free
);
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
;