You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
944B

  1. #include "util/util.hpp"
  2. #include <stdarg.h>
  3. namespace rack {
  4. FILE *gLogFile = stderr;
  5. void debug(const char *format, ...) {
  6. va_list args;
  7. va_start(args, format);
  8. fprintf(gLogFile, "[debug] ");
  9. vfprintf(gLogFile, format, args);
  10. fprintf(gLogFile, "\n");
  11. fflush(gLogFile);
  12. va_end(args);
  13. }
  14. void info(const char *format, ...) {
  15. va_list args;
  16. va_start(args, format);
  17. fprintf(gLogFile, "[info] ");
  18. vfprintf(gLogFile, format, args);
  19. fprintf(gLogFile, "\n");
  20. fflush(gLogFile);
  21. va_end(args);
  22. }
  23. void warn(const char *format, ...) {
  24. va_list args;
  25. va_start(args, format);
  26. fprintf(gLogFile, "[warning] ");
  27. vfprintf(gLogFile, format, args);
  28. fprintf(gLogFile, "\n");
  29. fflush(gLogFile);
  30. va_end(args);
  31. }
  32. void fatal(const char *format, ...) {
  33. va_list args;
  34. va_start(args, format);
  35. fprintf(gLogFile, "[fatal] ");
  36. vfprintf(gLogFile, format, args);
  37. fprintf(gLogFile, "\n");
  38. fflush(gLogFile);
  39. va_end(args);
  40. }
  41. } // namespace rack