log.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common_types.h"
  6. namespace Log {
  7. /// Specifies the severity or level of detail of the log message.
  8. enum class Level : u8 {
  9. Trace, ///< Extremely detailed and repetitive debugging information that is likely to
  10. /// pollute logs.
  11. Debug, ///< Less detailed debugging information.
  12. Info, ///< Status information from important points during execution.
  13. Warning, ///< Minor or potential problems found during execution of a task.
  14. Error, ///< Major problems found during execution of a task that prevent it from being
  15. /// completed.
  16. Critical, ///< Major problems during execution that threathen the stability of the entire
  17. /// application.
  18. Count ///< Total number of logging levels
  19. };
  20. typedef u8 ClassType;
  21. /**
  22. * Specifies the sub-system that generated the log message.
  23. *
  24. * @note If you add a new entry here, also add a corresponding one to `ALL_LOG_CLASSES` in
  25. * backend.cpp.
  26. */
  27. enum class Class : ClassType {
  28. Log, ///< Messages about the log system itself
  29. Common, ///< Library routines
  30. Common_Filesystem, ///< Filesystem interface library
  31. Common_Memory, ///< Memory mapping and management functions
  32. Core, ///< LLE emulation core
  33. Core_ARM11, ///< ARM11 CPU core
  34. Core_Timing, ///< CoreTiming functions
  35. Config, ///< Emulator configuration (including commandline)
  36. Debug, ///< Debugging tools
  37. Debug_Emulated, ///< Debug messages from the emulated programs
  38. Debug_GPU, ///< GPU debugging tools
  39. Debug_Breakpoint, ///< Logging breakpoints and watchpoints
  40. Debug_GDBStub, ///< GDB Stub
  41. Kernel, ///< The HLE implementation of the CTR kernel
  42. Kernel_SVC, ///< Kernel system calls
  43. Service, ///< HLE implementation of system services. Each major service
  44. /// should have its own subclass.
  45. Service_SRV, ///< The SRV (Service Directory) implementation
  46. Service_FRD, ///< The FRD (Friends) service
  47. Service_FS, ///< The FS (Filesystem) service implementation
  48. Service_ERR, ///< The ERR (Error) port implementation
  49. Service_APT, ///< The APT (Applets) service
  50. Service_BOSS, ///< The BOSS (SpotPass) service
  51. Service_GSP, ///< The GSP (GPU control) service
  52. Service_AC, ///< The AC (WiFi status) service
  53. Service_AM, ///< The AM (Application manager) service
  54. Service_PTM, ///< The PTM (Power status & misc.) service
  55. Service_LDR, ///< The LDR (3ds dll loader) service
  56. Service_MIC, ///< The MIC (microphone) service
  57. Service_NDM, ///< The NDM (Network daemon manager) service
  58. Service_NIM, ///< The NIM (Network interface manager) service
  59. Service_NWM, ///< The NWM (Network wlan manager) service
  60. Service_CAM, ///< The CAM (Camera) service
  61. Service_CECD, ///< The CECD (StreetPass) service
  62. Service_CFG, ///< The CFG (Configuration) service
  63. Service_DSP, ///< The DSP (DSP control) service
  64. Service_DLP, ///< The DLP (Download Play) service
  65. Service_HID, ///< The HID (Human interface device) service
  66. Service_SOC, ///< The SOC (Socket) service
  67. Service_IR, ///< The IR service
  68. Service_Y2R, ///< The Y2R (YUV to RGB conversion) service
  69. HW, ///< Low-level hardware emulation
  70. HW_Memory, ///< Memory-map and address translation
  71. HW_LCD, ///< LCD register emulation
  72. HW_GPU, ///< GPU control emulation
  73. Frontend, ///< Emulator UI
  74. Render, ///< Emulator video output and hardware acceleration
  75. Render_Software, ///< Software renderer backend
  76. Render_OpenGL, ///< OpenGL backend
  77. Audio, ///< Audio emulation
  78. Audio_DSP, ///< The HLE implementation of the DSP
  79. Audio_Sink, ///< Emulator audio output backend
  80. Loader, ///< ROM loader
  81. Count ///< Total number of logging classes
  82. };
  83. /// Logs a message to the global logger.
  84. void LogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
  85. const char* function,
  86. #ifdef _MSC_VER
  87. _Printf_format_string_
  88. #endif
  89. const char* format,
  90. ...)
  91. #ifdef __GNUC__
  92. __attribute__((format(printf, 6, 7)))
  93. #endif
  94. ;
  95. } // namespace Log
  96. #define LOG_GENERIC(log_class, log_level, ...) \
  97. ::Log::LogMessage(log_class, log_level, __FILE__, __LINE__, __func__, __VA_ARGS__)
  98. #ifdef _DEBUG
  99. #define LOG_TRACE(log_class, ...) \
  100. LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Trace, __VA_ARGS__)
  101. #else
  102. #define LOG_TRACE(log_class, ...) (void(0))
  103. #endif
  104. #define LOG_DEBUG(log_class, ...) \
  105. LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Debug, __VA_ARGS__)
  106. #define LOG_INFO(log_class, ...) \
  107. LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Info, __VA_ARGS__)
  108. #define LOG_WARNING(log_class, ...) \
  109. LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Warning, __VA_ARGS__)
  110. #define LOG_ERROR(log_class, ...) \
  111. LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Error, __VA_ARGS__)
  112. #define LOG_CRITICAL(log_class, ...) \
  113. LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Critical, __VA_ARGS__)