log.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 backend.cpp.
  25. */
  26. enum class Class : ClassType {
  27. Log, ///< Messages about the log system itself
  28. Common, ///< Library routines
  29. Common_Filesystem, ///< Filesystem interface library
  30. Common_Memory, ///< Memory mapping and management functions
  31. Core, ///< LLE emulation core
  32. Core_ARM11, ///< ARM11 CPU core
  33. Core_Timing, ///< CoreTiming functions
  34. Config, ///< Emulator configuration (including commandline)
  35. Debug, ///< Debugging tools
  36. Debug_Emulated, ///< Debug messages from the emulated programs
  37. Debug_GPU, ///< GPU debugging tools
  38. Debug_Breakpoint, ///< Logging breakpoints and watchpoints
  39. Debug_GDBStub, ///< GDB Stub
  40. Kernel, ///< The HLE implementation of the CTR kernel
  41. Kernel_SVC, ///< Kernel system calls
  42. Service, ///< HLE implementation of system services. Each major service
  43. /// should have its own subclass.
  44. Service_SRV, ///< The SRV (Service Directory) implementation
  45. Service_FS, ///< The FS (Filesystem) service implementation
  46. Service_ERR, ///< The ERR (Error) port implementation
  47. Service_APT, ///< The APT (Applets) service
  48. Service_GSP, ///< The GSP (GPU control) service
  49. Service_AC, ///< The AC (WiFi status) service
  50. Service_AM, ///< The AM (Application manager) service
  51. Service_PTM, ///< The PTM (Power status & misc.) service
  52. Service_LDR, ///< The LDR (3ds dll loader) service
  53. Service_NIM, ///< The NIM (Network interface manager) service
  54. Service_NWM, ///< The NWM (Network wlan manager) service
  55. Service_CAM, ///< The CAM (Camera) service
  56. Service_CFG, ///< The CFG (Configuration) service
  57. Service_DSP, ///< The DSP (DSP control) service
  58. Service_HID, ///< The HID (Human interface device) service
  59. Service_SOC, ///< The SOC (Socket) service
  60. Service_Y2R, ///< The Y2R (YUV to RGB conversion) service
  61. HW, ///< Low-level hardware emulation
  62. HW_Memory, ///< Memory-map and address translation
  63. HW_LCD, ///< LCD register emulation
  64. HW_GPU, ///< GPU control emulation
  65. Frontend, ///< Emulator UI
  66. Render, ///< Emulator video output and hardware acceleration
  67. Render_Software, ///< Software renderer backend
  68. Render_OpenGL, ///< OpenGL backend
  69. Audio, ///< Emulator audio output
  70. Audio_DSP, ///< The HLE implementation of the DSP
  71. Loader, ///< ROM loader
  72. Count ///< Total number of logging classes
  73. };
  74. /// Logs a message to the global logger.
  75. void LogMessage(Class log_class, Level log_level,
  76. const char* filename, unsigned int line_nr, const char* function,
  77. #ifdef _MSC_VER
  78. _Printf_format_string_
  79. #endif
  80. const char* format, ...)
  81. #ifdef __GNUC__
  82. __attribute__((format(printf, 6, 7)))
  83. #endif
  84. ;
  85. } // namespace Log
  86. #define LOG_GENERIC(log_class, log_level, ...) \
  87. ::Log::LogMessage(log_class, log_level, __FILE__, __LINE__, __func__, __VA_ARGS__)
  88. #ifdef _DEBUG
  89. #define LOG_TRACE( log_class, ...) LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Trace, __VA_ARGS__)
  90. #else
  91. #define LOG_TRACE( log_class, ...) (void(0))
  92. #endif
  93. #define LOG_DEBUG( log_class, ...) LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Debug, __VA_ARGS__)
  94. #define LOG_INFO( log_class, ...) LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Info, __VA_ARGS__)
  95. #define LOG_WARNING( log_class, ...) LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Warning, __VA_ARGS__)
  96. #define LOG_ERROR( log_class, ...) LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Error, __VA_ARGS__)
  97. #define LOG_CRITICAL(log_class, ...) LOG_GENERIC(::Log::Class::log_class, ::Log::Level::Critical, __VA_ARGS__)