diff options
author | Pawel Jakub Dawidek <pjd@FreeBSD.org> | 2010-08-05 18:26:38 +0000 |
---|---|---|
committer | Pawel Jakub Dawidek <pjd@FreeBSD.org> | 2010-08-05 18:26:38 +0000 |
commit | 524840d8d073477be6446924079367a5826883cb (patch) | |
tree | bb7796651ea6ec61e2de4c6f3974d3287c90b72e /sbin/hastd/pjdlog.c | |
parent | 60e1759be65f24985a5bedb9397d63ee61129ddb (diff) | |
download | src-524840d8d073477be6446924079367a5826883cb.tar.gz src-524840d8d073477be6446924079367a5826883cb.zip |
Problem with assertion is that it logs on stderr. Add two macros:
PJDLOG_ASSERT() and PJDLOG_VERIFY() that will check the given condition
and log the problem where appropriate. The difference between those
two is that PJDLOG_VERIFY() always work and PJDLOG_ASSERT() can be
turned off by defining NDEBUG.
MFC after: 1 month
Notes
Notes:
svn path=/head/; revision=210875
Diffstat (limited to 'sbin/hastd/pjdlog.c')
-rw-r--r-- | sbin/hastd/pjdlog.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sbin/hastd/pjdlog.c b/sbin/hastd/pjdlog.c index 34921e2b2a86..6891893cea84 100644 --- a/sbin/hastd/pjdlog.c +++ b/sbin/hastd/pjdlog.c @@ -365,3 +365,23 @@ pjdlog_exitx(int exitcode, const char *fmt, ...) /* NOTREACHED */ va_end(ap); } + +/* + * Log assertion and exit. + */ +void +pjdlog_verify(const char *func, const char *file, int line, + const char *failedexpr) +{ + + if (func == NULL) { + pjdlog_critical("Assertion failed: (%s), file %s, line %d.", + failedexpr, file, line); + } else { + pjdlog_critical("Assertion failed: (%s), function %s, file %s, line %d.", + failedexpr, func, file, line); + } + abort(); + /* NOTREACHED */ +} + |