backend.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 <chrono>
  6. #include <cstdarg>
  7. #include <string>
  8. #include <utility>
  9. #include "common/logging/log.h"
  10. namespace Log {
  11. class Filter;
  12. /**
  13. * A log entry. Log entries are store in a structured format to permit more varied output
  14. * formatting on different frontends, as well as facilitating filtering and aggregation.
  15. */
  16. struct Entry {
  17. std::chrono::microseconds timestamp;
  18. Class log_class;
  19. Level log_level;
  20. std::string location;
  21. std::string message;
  22. Entry() = default;
  23. // TODO(yuriks) Use defaulted move constructors once MSVC supports them
  24. #define MOVE(member) member(std::move(o.member))
  25. Entry(Entry&& o)
  26. : MOVE(timestamp), MOVE(log_class), MOVE(log_level),
  27. MOVE(location), MOVE(message)
  28. {}
  29. #undef MOVE
  30. Entry& operator=(const Entry&& o) {
  31. #define MOVE(member) member = std::move(o.member)
  32. MOVE(timestamp);
  33. MOVE(log_class);
  34. MOVE(log_level);
  35. MOVE(location);
  36. MOVE(message);
  37. #undef MOVE
  38. return *this;
  39. }
  40. };
  41. /**
  42. * Returns the name of the passed log class as a C-string. Subclasses are separated by periods
  43. * instead of underscores as in the enumeration.
  44. */
  45. const char* GetLogClassName(Class log_class);
  46. /**
  47. * Returns the name of the passed log level as a C-string.
  48. */
  49. const char* GetLevelName(Level log_level);
  50. /// Creates a log entry by formatting the given source location, and message.
  51. Entry CreateEntry(Class log_class, Level log_level,
  52. const char* filename, unsigned int line_nr, const char* function,
  53. const char* format, va_list args);
  54. void SetFilter(Filter* filter);
  55. }