summaryrefslogtreecommitdiffstats
path: root/src/egl/main/egllog.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-11-23 01:37:30 +0000
committerBrian Paul <[email protected]>2005-11-23 01:37:30 +0000
commitf049ca4e33e0e5d06223a1c05815bc564b4bf06e (patch)
tree18fde934dd1fd60a2decf47ce2629021615c20f8 /src/egl/main/egllog.c
parent9bcc9e91745a6125f31d127410ac38e99660da67 (diff)
New _eglLog() function to replace fprintf/printf calls for debug/info.
Diffstat (limited to 'src/egl/main/egllog.c')
-rw-r--r--src/egl/main/egllog.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c
new file mode 100644
index 00000000000..59b1d2684e3
--- /dev/null
+++ b/src/egl/main/egllog.c
@@ -0,0 +1,57 @@
+/**
+ * Logging facility for debug/info messages.
+ */
+
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "egllog.h"
+
+#define MAXSTRING 1000
+
+
+/* XXX init this with an env var or something */
+static EGLint ReportingLevel = _EGL_DEBUG;
+
+
+/**
+ * Log a message to stderr.
+ * \param level one of _EGL_FATAL, _EGL_WARNING, _EGL_INFO, _EGL_DEBUG.
+ */
+void
+_eglLog(EGLint level, const char *fmtStr, ...)
+{
+ va_list args;
+ char msg[MAXSTRING];
+ const char *levelStr;
+
+ if (level <= ReportingLevel) {
+ switch (level) {
+ case _EGL_FATAL:
+ levelStr = "Fatal";
+ break;
+ case _EGL_WARNING:
+ levelStr = "Warning";
+ break;
+ case _EGL_INFO:
+ levelStr = "Info";
+ break;
+ case _EGL_DEBUG:
+ levelStr = "Debug";
+ break;
+ default:
+ levelStr = "";
+ }
+
+ va_start(args, fmtStr);
+ vsnprintf(msg, MAXSTRING, fmtStr, args);
+ va_end(args);
+
+ fprintf(stderr, "EGL %s: %s\n", levelStr, msg);
+
+ if (level == _EGL_FATAL) {
+ exit(1); /* or abort()? */
+ }
+ }
+}