?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /* debug.c - library for logging debug messages.
  2.  
  3.    This is free and unencumbered software released into the public domain.
  4.    For more information, please refer to <http://unlicense.org>. */
  5.  
  6. #include "defs.h"
  7.  
  8. #include <stdarg.h>
  9. #include <stdio.h>
  10. #include "debug.h"
  11.  
  12. void _DEBUG (const char *file, int line, const char *func, const char *format, ...)
  13. {
  14.     va_list ap;
  15.  
  16.     va_start (ap, format);
  17.  
  18.     fprintf (stderr, "%s", "DEBUG");
  19.  
  20.     if (file)
  21.         fprintf (stderr, ":%s", file);
  22.  
  23.     if (line)
  24.         fprintf (stderr, ":%d", line);
  25.  
  26.     if (func)
  27.         fprintf (stderr, ":%s()", func);
  28.  
  29.     fprintf (stderr, "%s", ": ");
  30.  
  31.     if (format)
  32.         vfprintf (stderr, format, ap);
  33.  
  34.     va_end (ap);
  35.  
  36.     fprintf (stderr, NL);
  37. }
  38.  
  39. void _PERROR (const char *file, int line, const char *func, const char *text)
  40. {
  41.     _DEBUG (file, line, func, "%s() failed.", text);
  42. }
  43.