2 * Copyright 2004-2005 Timo Hirvonen
12 static FILE *debug_stream
= NULL
;
19 const char *tmp
= getenv("TMPDIR");
24 snprintf(filename
, sizeof(filename
), "%s/cmus-debug", tmp
);
25 debug_stream
= fopen(filename
, "w");
26 if (debug_stream
== NULL
)
27 die_errno("error opening `%s' for writing", filename
);
31 /* This function must be defined even if debugging is disabled in the program
32 * because debugging might still be enabled in some plugin.
34 void __debug_bug(const char *function
, const char *fmt
, ...)
36 const char *format
= "\n%s: BUG: ";
39 /* debug_stream exists only if debugging is enabled */
41 fprintf(debug_stream
, format
, function
);
43 vfprintf(debug_stream
, fmt
, ap
);
47 /* always print bug message to stderr */
48 fprintf(stderr
, format
, function
);
50 vfprintf(stderr
, fmt
, ap
);
55 void __debug_print(const char *function
, const char *fmt
, ...)
60 fprintf(debug_stream
, "%s: ", function
);
62 vfprintf(debug_stream
, fmt
, ap
);