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.
 
 
 

87 regels
1.6 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://sam.zoy.org/projects/COPYING.WTFPL for more details.
  9. //
  10. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include <cmath>
  14. #include <cstdio>
  15. #if defined __ANDROID__
  16. # include <android/log.h>
  17. #else
  18. # include <cstdarg>
  19. #endif
  20. #include "core.h"
  21. namespace lol
  22. {
  23. /*
  24. * Public Log class
  25. */
  26. void Log::Debug(char const *fmt, ...)
  27. {
  28. va_list ap;
  29. va_start(ap, fmt);
  30. #if defined __ANDROID__
  31. __android_log_vprint(ANDROID_LOG_DEBUG, "LOL", fmt, ap);
  32. #else
  33. fprintf(stderr, "DEBUG: ");
  34. vfprintf(stderr, fmt, ap);
  35. #endif
  36. va_end(ap);
  37. }
  38. void Log::Info(char const *fmt, ...)
  39. {
  40. va_list ap;
  41. va_start(ap, fmt);
  42. #if defined __ANDROID__
  43. __android_log_vprint(ANDROID_LOG_INFO, "LOL", fmt, ap);
  44. #else
  45. fprintf(stderr, "INFO: ");
  46. vfprintf(stderr, fmt, ap);
  47. #endif
  48. va_end(ap);
  49. }
  50. void Log::Warn(char const *fmt, ...)
  51. {
  52. va_list ap;
  53. va_start(ap, fmt);
  54. #if defined __ANDROID__
  55. __android_log_vprint(ANDROID_LOG_WARN, "LOL", fmt, ap);
  56. #else
  57. fprintf(stderr, "WARN: ");
  58. vfprintf(stderr, fmt, ap);
  59. #endif
  60. va_end(ap);
  61. }
  62. void Log::Error(char const *fmt, ...)
  63. {
  64. va_list ap;
  65. va_start(ap, fmt);
  66. #if defined __ANDROID__
  67. __android_log_vprint(ANDROID_LOG_ERROR, "LOL", fmt, ap);
  68. #else
  69. fprintf(stderr, "ERROR: ");
  70. vfprintf(stderr, fmt, ap);
  71. #endif
  72. va_end(ap);
  73. }
  74. } /* namespace lol */