mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-21 19:21:47 +00:00
Add diagnostic hooks.
This commit is contained in:
parent
d95c01be1a
commit
673b45be05
2 changed files with 31 additions and 1 deletions
|
@ -38,6 +38,12 @@
|
||||||
*/
|
*/
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
|
typedef void (*diagnostic_hook)(const char *message);
|
||||||
|
extern diagnostic_hook bug_hook;
|
||||||
|
extern diagnostic_hook error_hook;
|
||||||
|
extern diagnostic_hook warning_hook;
|
||||||
|
extern diagnostic_hook notice_hook;
|
||||||
|
|
||||||
struct expr_s *error (struct expr_s *e, const char *fmt, ...)
|
struct expr_s *error (struct expr_s *e, const char *fmt, ...)
|
||||||
__attribute__ ((format (printf, 2, 3)));
|
__attribute__ ((format (printf, 2, 3)));
|
||||||
void
|
void
|
||||||
|
|
|
@ -41,6 +41,11 @@
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "strpool.h"
|
#include "strpool.h"
|
||||||
|
|
||||||
|
diagnostic_hook bug_hook;
|
||||||
|
diagnostic_hook error_hook;
|
||||||
|
diagnostic_hook warning_hook;
|
||||||
|
diagnostic_hook notice_hook;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
report_function (expr_t *e)
|
report_function (expr_t *e)
|
||||||
{
|
{
|
||||||
|
@ -103,6 +108,11 @@ _warning (expr_t *e, const char *fmt, va_list args)
|
||||||
}
|
}
|
||||||
|
|
||||||
format_message (message, "warning", e, fmt, args);
|
format_message (message, "warning", e, fmt, args);
|
||||||
|
if (warning_hook) {
|
||||||
|
warning_hook (message->str);
|
||||||
|
} else {
|
||||||
|
fprintf (stderr, "%s\n", message->str);
|
||||||
|
}
|
||||||
fprintf (stderr, "%s\n", message->str);
|
fprintf (stderr, "%s\n", message->str);
|
||||||
dstring_delete (message);
|
dstring_delete (message);
|
||||||
}
|
}
|
||||||
|
@ -139,7 +149,11 @@ bug (expr_t *e, const char *fmt, ...)
|
||||||
dstring_t *message = dstring_new ();
|
dstring_t *message = dstring_new ();
|
||||||
|
|
||||||
format_message (message, "BUG", e, fmt, args);
|
format_message (message, "BUG", e, fmt, args);
|
||||||
fprintf (stderr, "%s\n", message->str);
|
if (bug_hook) {
|
||||||
|
bug_hook (message->str);
|
||||||
|
} else {
|
||||||
|
fprintf (stderr, "%s\n", message->str);
|
||||||
|
}
|
||||||
dstring_delete (message);
|
dstring_delete (message);
|
||||||
}
|
}
|
||||||
va_end (args);
|
va_end (args);
|
||||||
|
@ -162,6 +176,11 @@ notice (expr_t *e, const char *fmt, ...)
|
||||||
report_function (e);
|
report_function (e);
|
||||||
|
|
||||||
format_message (message, "notice", e, fmt, args);
|
format_message (message, "notice", e, fmt, args);
|
||||||
|
if (notice_hook) {
|
||||||
|
notice_hook (message->str);
|
||||||
|
} else {
|
||||||
|
fprintf (stderr, "%s\n", message->str);
|
||||||
|
}
|
||||||
fprintf (stderr, "%s\n", message->str);
|
fprintf (stderr, "%s\n", message->str);
|
||||||
dstring_delete (message);
|
dstring_delete (message);
|
||||||
}
|
}
|
||||||
|
@ -211,6 +230,11 @@ error (expr_t *e, const char *fmt, ...)
|
||||||
dstring_t *message = dstring_new ();
|
dstring_t *message = dstring_new ();
|
||||||
|
|
||||||
format_message (message, "error", e, fmt, args);
|
format_message (message, "error", e, fmt, args);
|
||||||
|
if (error_hook) {
|
||||||
|
error_hook (message->str);
|
||||||
|
} else {
|
||||||
|
fprintf (stderr, "%s\n", message->str);
|
||||||
|
}
|
||||||
fprintf (stderr, "%s\n", message->str);
|
fprintf (stderr, "%s\n", message->str);
|
||||||
dstring_delete (message);
|
dstring_delete (message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue