JustEnoughMod
Loading...
Searching...
No Matches
Logger.hpp
1#ifndef CORE_LOGGER_HPP
2#define CORE_LOGGER_HPP
3
4#include <spdlog/spdlog.h>
5
6namespace JEM {
7 class Logger {
8 public:
9 explicit Logger(std::string name);
10
11 template <typename... Args>
12 constexpr auto trace(spdlog::format_string_t<Args...> fmt, Args &&...args) -> void {
13 m_logger->trace(fmt, std::forward<Args>(args)...);
14 }
15
16 template <typename... Args>
17 constexpr auto debug(spdlog::format_string_t<Args...> fmt, Args &&...args) -> void {
18 m_logger->debug(fmt, std::forward<Args>(args)...);
19 }
20
21 template <typename... Args>
22 constexpr auto info(spdlog::format_string_t<Args...> fmt, Args &&...args) -> void {
23 m_logger->info(fmt, std::forward<Args>(args)...);
24 }
25
26 template <typename... Args>
27 constexpr auto warn(spdlog::format_string_t<Args...> fmt, Args &&...args) -> void {
28 m_logger->warn(fmt, std::forward<Args>(args)...);
29 }
30
31 template <typename... Args>
32 constexpr auto error(spdlog::format_string_t<Args...> fmt, Args &&...args) -> void {
33 m_logger->error(fmt, std::forward<Args>(args)...);
34 }
35
36 template <typename... Args>
37 constexpr auto critical(spdlog::format_string_t<Args...> fmt, Args &&...args) -> void {
38 m_logger->critical(fmt, std::forward<Args>(args)...);
39 m_logger->critical("Application exit due to critical error!");
40 exit(EXIT_FAILURE);
41 }
42
43 [[nodiscard]] auto getName() const -> std::string {
44 return m_name;
45 }
46
47 private:
48 std::shared_ptr<spdlog::logger> m_logger;
49
50 std::string m_name;
51 };
52
53 auto getSystemLogger() -> Logger *;
54 auto getVulkanLogger() -> Logger *;
55} // namespace JEM
56
57#endif
Definition Logger.hpp:7