2 * Copyright (C) 2006 Martin Willi
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 ENUM(debug_names
, DBG_DMN
, DBG_LIB
,
41 ENUM(debug_lower_names
, DBG_DMN
, DBG_LIB
,
63 * level logged by the default logger
65 static level_t default_level
= 1;
68 * stream logged to by the default logger
70 static FILE *default_stream
= NULL
;
73 * default dbg function which printf all to stderr
75 void dbg_default(debug_t group
, level_t level
, char *fmt
, ...)
79 default_stream
= stderr
;
81 if (level
<= default_level
)
86 vfprintf(default_stream
, fmt
, args
);
87 fprintf(default_stream
, "\n");
93 * set the level logged by the default stderr logger
95 void dbg_default_set_level(level_t level
)
97 default_level
= level
;
101 * set the stream logged by dbg_default() to
103 void dbg_default_set_stream(FILE *stream
)
105 default_stream
= stream
;
109 * The registered debug hook.
111 void (*dbg
) (debug_t group
, level_t level
, char *fmt
, ...) = dbg_default
;