Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

115 rindas
2.8KB

  1. // Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
  2. // Distributed under the MIT License (http://opensource.org/licenses/MIT)
  3. #pragma once
  4. #ifndef SPDLOG_HEADER_ONLY
  5. #include "spdlog/spdlog.h"
  6. #endif
  7. #include "spdlog/common.h"
  8. #include "spdlog/details/pattern_formatter.h"
  9. namespace spdlog {
  10. SPDLOG_INLINE void initialize_logger(std::shared_ptr<logger> logger)
  11. {
  12. details::registry::instance().initialize_logger(std::move(logger));
  13. }
  14. SPDLOG_INLINE std::shared_ptr<logger> get(const std::string &name)
  15. {
  16. return details::registry::instance().get(name);
  17. }
  18. SPDLOG_INLINE void set_formatter(std::unique_ptr<spdlog::formatter> formatter)
  19. {
  20. details::registry::instance().set_formatter(std::move(formatter));
  21. }
  22. SPDLOG_INLINE void set_pattern(std::string pattern, pattern_time_type time_type)
  23. {
  24. set_formatter(std::unique_ptr<spdlog::formatter>(new pattern_formatter(std::move(pattern), time_type)));
  25. }
  26. SPDLOG_INLINE void enable_backtrace(size_t n_messages)
  27. {
  28. details::registry::instance().enable_backtrace(n_messages);
  29. }
  30. SPDLOG_INLINE void disable_backtrace()
  31. {
  32. details::registry::instance().disable_backtrace();
  33. }
  34. SPDLOG_INLINE void dump_backtrace()
  35. {
  36. default_logger_raw()->dump_backtrace();
  37. }
  38. SPDLOG_INLINE void set_level(level::level_enum log_level)
  39. {
  40. details::registry::instance().set_level(log_level);
  41. }
  42. SPDLOG_INLINE void flush_on(level::level_enum log_level)
  43. {
  44. details::registry::instance().flush_on(log_level);
  45. }
  46. SPDLOG_INLINE void flush_every(std::chrono::seconds interval)
  47. {
  48. details::registry::instance().flush_every(interval);
  49. }
  50. SPDLOG_INLINE void set_error_handler(void (*handler)(const std::string &msg))
  51. {
  52. details::registry::instance().set_error_handler(handler);
  53. }
  54. SPDLOG_INLINE void register_logger(std::shared_ptr<logger> logger)
  55. {
  56. details::registry::instance().register_logger(std::move(logger));
  57. }
  58. SPDLOG_INLINE void apply_all(const std::function<void(std::shared_ptr<logger>)> &fun)
  59. {
  60. details::registry::instance().apply_all(fun);
  61. }
  62. SPDLOG_INLINE void drop(const std::string &name)
  63. {
  64. details::registry::instance().drop(name);
  65. }
  66. SPDLOG_INLINE void drop_all()
  67. {
  68. details::registry::instance().drop_all();
  69. }
  70. SPDLOG_INLINE void shutdown()
  71. {
  72. details::registry::instance().shutdown();
  73. }
  74. SPDLOG_INLINE void set_automatic_registration(bool automatic_registation)
  75. {
  76. details::registry::instance().set_automatic_registration(automatic_registation);
  77. }
  78. SPDLOG_INLINE std::shared_ptr<spdlog::logger> default_logger()
  79. {
  80. return details::registry::instance().default_logger();
  81. }
  82. SPDLOG_INLINE spdlog::logger *default_logger_raw()
  83. {
  84. return details::registry::instance().get_default_raw();
  85. }
  86. SPDLOG_INLINE void set_default_logger(std::shared_ptr<spdlog::logger> default_logger)
  87. {
  88. details::registry::instance().set_default_logger(std::move(default_logger));
  89. }
  90. } // namespace spdlog