CommonLibSSE (Parapets fork)
Logger.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSTEvent.h"
4 #include "RE/L/LogEvent.h"
5 
6 #define SKSE_MAKE_SOURCE_LOGGER(a_func, a_type) \
7  \
8  template <class... Args> \
9  struct [[maybe_unused]] a_func \
10  { \
11  a_func() = delete; \
12  \
13  explicit a_func( \
14  fmt::format_string<Args...> a_fmt, \
15  Args&&... a_args, \
16  std::source_location a_loc = std::source_location::current()) \
17  { \
18  spdlog::log( \
19  spdlog::source_loc{ \
20  a_loc.file_name(), \
21  static_cast<int>(a_loc.line()), \
22  a_loc.function_name() }, \
23  spdlog::level::a_type, \
24  a_fmt, \
25  std::forward<Args>(a_args)...); \
26  } \
27  }; \
28  \
29  template <class... Args> \
30  a_func(fmt::format_string<Args...>, Args&&...) -> a_func<Args...>;
31 
32 namespace SKSE::log
33 {
34  SKSE_MAKE_SOURCE_LOGGER(trace, trace);
35  SKSE_MAKE_SOURCE_LOGGER(debug, debug);
39  SKSE_MAKE_SOURCE_LOGGER(critical, critical);
40 
41  [[nodiscard]] std::optional<std::filesystem::path> log_directory();
42 
43  void add_papyrus_sink(std::regex a_filter);
45 }
46 
47 #undef SKSE_MAKE_SOURCE_LOGGER
Definition: Logger.h:33
std::optional< std::filesystem::path > log_directory()
void remove_papyrus_sink()
SKSE_MAKE_SOURCE_LOGGER(trace, trace)
void add_papyrus_sink(std::regex a_filter)