2 * Copyright 2004-2005 Timo Hirvonen
12 static FILE *debug_stream
= NULL
;
18 const char *debug_filename
= "/tmp/cmus-debug";
20 debug_stream
= fopen(debug_filename
, "w");
21 if (debug_stream
== NULL
)
22 die_errno("error opening `%s' for writing", debug_filename
);
26 /* This function must be defined even if debugging is disabled in the program
27 * because debugging might still be enabled in some plugin.
29 void __debug_bug(const char *function
, const char *fmt
, ...)
31 const char *format
= "\n%s: BUG: ";
34 /* debug_stream exists only if debugging is enabled */
36 fprintf(debug_stream
, format
, function
);
38 vfprintf(debug_stream
, fmt
, ap
);
42 /* always print bug message to stderr */
43 fprintf(stderr
, format
, function
);
45 vfprintf(stderr
, fmt
, ap
);
50 void __debug_print(const char *function
, const char *fmt
, ...)
55 fprintf(debug_stream
, "%s: ", function
);
57 vfprintf(debug_stream
, fmt
, ap
);