Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

86 řádky
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 <cstdio>
  14. #if defined __ANDROID__
  15. # include <android/log.h>
  16. #else
  17. # include <cstdarg>
  18. #endif
  19. #include "core.h"
  20. namespace lol
  21. {
  22. /*
  23. * Public Log class
  24. */
  25. void Log::Debug(char const *fmt, ...)
  26. {
  27. va_list ap;
  28. va_start(ap, fmt);
  29. #if defined __ANDROID__
  30. __android_log_vprint(ANDROID_LOG_DEBUG, "LOL", fmt, ap);
  31. #else
  32. fprintf(stderr, "DEBUG: ");
  33. vfprintf(stderr, fmt, ap);
  34. #endif
  35. va_end(ap);
  36. }
  37. void Log::Info(char const *fmt, ...)
  38. {
  39. va_list ap;
  40. va_start(ap, fmt);
  41. #if defined __ANDROID__
  42. __android_log_vprint(ANDROID_LOG_INFO, "LOL", fmt, ap);
  43. #else
  44. fprintf(stderr, "INFO: ");
  45. vfprintf(stderr, fmt, ap);
  46. #endif
  47. va_end(ap);
  48. }
  49. void Log::Warn(char const *fmt, ...)
  50. {
  51. va_list ap;
  52. va_start(ap, fmt);
  53. #if defined __ANDROID__
  54. __android_log_vprint(ANDROID_LOG_WARN, "LOL", fmt, ap);
  55. #else
  56. fprintf(stderr, "WARN: ");
  57. vfprintf(stderr, fmt, ap);
  58. #endif
  59. va_end(ap);
  60. }
  61. void Log::Error(char const *fmt, ...)
  62. {
  63. va_list ap;
  64. va_start(ap, fmt);
  65. #if defined __ANDROID__
  66. __android_log_vprint(ANDROID_LOG_ERROR, "LOL", fmt, ap);
  67. #else
  68. fprintf(stderr, "ERROR: ");
  69. vfprintf(stderr, fmt, ap);
  70. #endif
  71. va_end(ap);
  72. }
  73. } /* namespace lol */