backend.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 filename;
  21. unsigned int line_num;
  22. std::string function;
  23. std::string message;
  24. Entry() = default;
  25. Entry(Entry&& o) = default;
  26. Entry& operator=(Entry&& o) = default;
  27. Entry& operator=(const Entry& o) = default;
  28. };
  29. /**
  30. * Returns the name of the passed log class as a C-string. Subclasses are separated by periods
  31. * instead of underscores as in the enumeration.
  32. */
  33. const char* GetLogClassName(Class log_class);
  34. /**
  35. * Returns the name of the passed log level as a C-string.
  36. */
  37. const char* GetLevelName(Level log_level);
  38. /// Creates a log entry by formatting the given source location, and message.
  39. Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
  40. const char* function, std::string message);
  41. void SetFilter(Filter* filter);
  42. } // namespace Log