Log.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
  3. Permission is hereby granted, free of charge, to any person
  4. obtaining a copy of this software and associated documentation
  5. files (the "Software"), to deal in the Software without
  6. restriction, including without limitation the rights to use,
  7. copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the
  9. Software is furnished to do so, subject to the following
  10. conditions:
  11. The above copyright notice and this permission notice shall be
  12. included in all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  15. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  17. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  18. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #pragma once
  23. #include "Str.h"
  24. namespace crown
  25. {
  26. /**
  27. Enumerates log levels.
  28. */
  29. enum LogLevel
  30. {
  31. LL_INFO = 0,
  32. LL_WARN = 1,
  33. LL_ERROR = 2,
  34. LL_DEBUG = 3
  35. };
  36. class Log
  37. {
  38. public:
  39. static LogLevel GetThreshold();
  40. static void SetThreshold(LogLevel threshold);
  41. static void LogMessage(LogLevel level, const char* message, va_list arg);
  42. static void D(const char* message, ...);
  43. static void E(const char* message, ...);
  44. static void W(const char* message, ...);
  45. static void I(const char* message, ...);
  46. static void IndentIn();
  47. static void IndentOut();
  48. private:
  49. static LogLevel mThreshold;
  50. static int32_t mIndentCount;
  51. };
  52. } // namespace crown