~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/egl/main/egllog.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-21 12:44:07 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20070221124407-rgcacs32mycrtadl
ImportĀ upstreamĀ versionĀ 6.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * Logging facility for debug/info messages.
3
 
 */
4
 
 
5
 
 
6
 
#include <stdarg.h>
7
 
#include <stdio.h>
8
 
#include <stdlib.h>
9
 
#include "egllog.h"
10
 
 
11
 
#define MAXSTRING 1000
12
 
 
13
 
 
14
 
/* XXX init this with an env var or something */
15
 
static EGLint ReportingLevel = _EGL_DEBUG;
16
 
 
17
 
 
18
 
/**
19
 
 * Log a message to stderr.
20
 
 * \param level one of _EGL_FATAL, _EGL_WARNING, _EGL_INFO, _EGL_DEBUG.
21
 
 */
22
 
void
23
 
_eglLog(EGLint level, const char *fmtStr, ...)
24
 
{
25
 
   va_list args;
26
 
   char msg[MAXSTRING];
27
 
   const char *levelStr;
28
 
 
29
 
   if (level <= ReportingLevel) {
30
 
      switch (level) {
31
 
      case _EGL_FATAL:
32
 
         levelStr = "Fatal";
33
 
         break;
34
 
      case _EGL_WARNING:
35
 
         levelStr = "Warning";
36
 
         break;
37
 
      case _EGL_INFO:
38
 
         levelStr = "Info";
39
 
         break;
40
 
      case _EGL_DEBUG:
41
 
         levelStr = "Debug";
42
 
         break;
43
 
      default:
44
 
         levelStr = "";
45
 
      }
46
 
 
47
 
      va_start(args, fmtStr);
48
 
      vsnprintf(msg, MAXSTRING, fmtStr, args);
49
 
      va_end(args);
50
 
 
51
 
      fprintf(stderr, "EGL %s: %s\n", levelStr, msg);
52
 
 
53
 
      if (level == _EGL_FATAL) {
54
 
         exit(1); /* or abort()? */
55
 
      }
56
 
   }
57
 
}