summaryrefslogtreecommitdiffstats
path: root/src/reporting.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/reporting.h')
-rw-r--r--src/reporting.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/reporting.h b/src/reporting.h
new file mode 100644
index 0000000..c4f1c60
--- /dev/null
+++ b/src/reporting.h
@@ -0,0 +1,28 @@
+#ifndef REPORTING_H
+#define REPORTING_H
+
+/* message severity levels */
+#define REPORT_ALERT 0
+#define REPORT_ERROR 1
+#define REPORT_WARNING 2
+#define REPORT_INFO 3
+#define REPORT_DEBUG 4
+
+extern int verbosity_level;
+
+void reporting_init(const char *program_name);
+void reporting_use_syslog(int flag);
+void reporting_verbosity(int level); /* setter */
+
+/* rather than using report_message directly, use one of the below macros */
+void report_message(int level, const char *format, ...);
+void report_private_message(int level, const char *format, ...);
+
+/* macros are used to minimize the performance impact of disabled (due to verbosity level) 'report' calls */
+#define report_alert(format, ...) if(REPORT_ALERT <= verbosity_level) report_message(REPORT_ALERT, format, ##__VA_ARGS__)
+#define report_error(format, ...) if(REPORT_ERROR <= verbosity_level) report_message(REPORT_ERROR, format, ##__VA_ARGS__)
+#define report_warning(format, ...) if(REPORT_WARNING <= verbosity_level) report_message(REPORT_WARNING, format, ##__VA_ARGS__)
+#define report_info(format, ...) if(REPORT_INFO <= verbosity_level) report_message(REPORT_INFO, format, ##__VA_ARGS__)
+#define report_debug(format, ...) if(REPORT_DEBUG <= verbosity_level) report_message(REPORT_DEBUG, format, ##__VA_ARGS__)
+
+#endif \ No newline at end of file