14namespace pixelbullet::log
26inline constexpr std::array<const char*, static_cast<std::size_t>(Level::count)> level_strings = {
"TRACE",
"INFO",
"WARN",
"ERROR",
29inline constexpr const char* to_string(
const Level level)
noexcept
31 const std::size_t index =
static_cast<std::size_t
>(level);
32 return index < level_strings.size() ? level_strings[index] :
"UNKNOWN";
37 std::filesystem::path root_directory;
38 std::size_t retained_session_count = 20;
39 bool allow_environment_override =
true;
44 std::string timestamp_iso8601;
46 uint32_t process_id = 0;
47 std::string thread_id;
48 Level severity = Level::Info;
49 std::string logger_name;
56 explicit Logger(std::string name);
58 [[nodiscard]]
const std::string& name()
const
63 template <
typename... Args>
64 void trace(fmt::format_string<Args...> fmt_str, Args&&... args)
const
66 write(Level::Trace, fmt::format(fmt_str, std::forward<Args>(args)...));
69 template <
typename... Args>
70 void info(fmt::format_string<Args...> fmt_str, Args&&... args)
const
72 write(Level::Info, fmt::format(fmt_str, std::forward<Args>(args)...));
75 template <
typename... Args>
76 void warn(fmt::format_string<Args...> fmt_str, Args&&... args)
const
78 write(Level::Warn, fmt::format(fmt_str, std::forward<Args>(args)...));
81 template <
typename... Args>
82 void error(fmt::format_string<Args...> fmt_str, Args&&... args)
const
84 write(Level::Error, fmt::format(fmt_str, std::forward<Args>(args)...));
87 template <
typename... Args>
88 void critical(fmt::format_string<Args...> fmt_str, Args&&... args)
const
90 write(Level::Critical, fmt::format(fmt_str, std::forward<Args>(args)...));
94 void write(Level level, std::string message)
const;
100namespace pixelbullet::logging
104 std::string binary_path;
105 std::filesystem::path log_directory_override;
110 std::string client_name;
111 std::string client_version;
112 std::string engine_name;
113 std::string engine_version;
118inline constexpr std::string_view core =
"core";
119inline constexpr std::string_view core_app =
"core.app";
120inline constexpr std::string_view core_graphics =
"core.graphics";
121inline constexpr std::string_view core_image =
"core.image";
122inline constexpr std::string_view core_assets =
"core.assets";
123inline constexpr std::string_view core_shader =
"core.shader";
124inline constexpr std::string_view core_ui =
"core.ui";
126inline constexpr std::string_view client =
"client";
128inline constexpr std::string_view vulkan_validation =
"vulkan.validation";
131void initialize(
const StartupInfo& startup_info,
const log::LogConfig& config = {});
134[[nodiscard]]
bool is_initialized();
135[[nodiscard]] std::shared_ptr<log::Logger> get(std::string_view name);
137void update_session_metadata(
const SessionMetadata& metadata);
139[[nodiscard]] std::filesystem::path log_root();
140[[nodiscard]] std::filesystem::path session_directory();
141[[nodiscard]] std::filesystem::path latest_manifest_path();
144namespace pixelbullet::log
146template <
typename... Args>
147void trace(fmt::format_string<Args...> fmt_str, Args&&... args)
149 logging::get(logging::names::core)->trace(fmt_str, std::forward<Args>(args)...);
152template <
typename... Args>
153void info(fmt::format_string<Args...> fmt_str, Args&&... args)
155 logging::get(logging::names::core)->info(fmt_str, std::forward<Args>(args)...);
158template <
typename... Args>
159void warn(fmt::format_string<Args...> fmt_str, Args&&... args)
161 logging::get(logging::names::core)->warn(fmt_str, std::forward<Args>(args)...);
164template <
typename... Args>
165void error(fmt::format_string<Args...> fmt_str, Args&&... args)
167 logging::get(logging::names::core)->error(fmt_str, std::forward<Args>(args)...);
170template <
typename... Args>
171void critical(fmt::format_string<Args...> fmt_str, Args&&... args)
173 logging::get(logging::names::core)->critical(fmt_str, std::forward<Args>(args)...);