summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-11-25 14:09:15 -0500
committerTavian Barnes <tavianator@gmail.com>2009-11-25 14:09:15 -0500
commit640917131f4f403f1d84ee2ff4d5a33c08a9c53a (patch)
tree84d840d9fb62eecbad83bbea6e9d61ca49915d23
parent32f46ae1ccdb01533ea61265e4c977b9307c710d (diff)
downloaddimension-640917131f4f403f1d84ee2ff4d5a33c08a9c53a.tar.xz
Add source filename to dmnsn_error() output.
-rw-r--r--libdimension/dimension/error.h7
-rw-r--r--libdimension/error.c9
2 files changed, 11 insertions, 5 deletions
diff --git a/libdimension/dimension/error.h b/libdimension/dimension/error.h
index caee303..cc9e248 100644
--- a/libdimension/dimension/error.h
+++ b/libdimension/dimension/error.h
@@ -44,11 +44,14 @@ typedef enum {
/* Use this macro to report an error */
#define dmnsn_error(severity, str) \
- dmnsn_report_error((dmnsn_severity)(severity), DMNSN_FUNC, __LINE__, (str))
+ dmnsn_report_error((dmnsn_severity)(severity), \
+ DMNSN_FUNC, __FILE__, __LINE__, \
+ str)
/* Called by dmnsn_error() - don't call directly */
void dmnsn_report_error(dmnsn_severity severity,
- const char *func, unsigned int line, const char *str);
+ const char *func, const char *file, unsigned int line,
+ const char *str);
/* Get and set the library resilience, thread-safely */
dmnsn_severity dmnsn_get_resilience();
diff --git a/libdimension/error.c b/libdimension/error.c
index c3c9b60..32efd6c 100644
--- a/libdimension/error.c
+++ b/libdimension/error.c
@@ -37,17 +37,20 @@ static pthread_mutex_t dmnsn_fatal_mutex = PTHREAD_MUTEX_INITIALIZER;
/* Called by dmnsn_error macro (don't call directly). */
void
-dmnsn_report_error(dmnsn_severity severity, const char *func, unsigned int line,
+dmnsn_report_error(dmnsn_severity severity,
+ const char *func, const char *file, unsigned int line,
const char *str)
{
if (severity >= dmnsn_get_resilience()) {
/* An error more severe than our resilience happened, bail out */
- fprintf(stderr, "Dimension ERROR: %s, line %u: %s\n", func, line, str);
+ fprintf(stderr, "Dimension ERROR: %s, %s:%u: %s\n",
+ func, file, line, str);
(*dmnsn_fatal)();
exit(EXIT_FAILURE); /* Failsafe in case *dmnsn_fatal doesn't exit */
} else {
/* A trivial error happened, warn and continue */
- fprintf(stderr, "Dimension WARNING: %s, line %u: %s\n", func, line, str);
+ fprintf(stderr, "Dimension WARNING: %s, %s:%u: %s\n",
+ func, file, line, str);
}
}