4#include "pixelbullet/application/log.h"
13#include <unordered_map>
15namespace pixelbullet::logging_internal
17using SystemClock = std::chrono::system_clock;
18using SteadyClock = std::chrono::steady_clock;
32 explicit TextFileSink(
const std::filesystem::path& path);
38 std::ofstream stream_;
44 explicit NdjsonSink(
const std::filesystem::path& path);
50 std::ofstream stream_;
55 std::string started_at;
57 uint32_t process_id = 0;
58 bool used_environment_override =
false;
59 std::string binary_stem;
60 std::filesystem::path binary_path;
61 std::filesystem::path current_working_directory;
62 std::filesystem::path log_root;
63 std::filesystem::path session_directory;
64 std::filesystem::path latest_manifest_path;
65 std::filesystem::path session_log_path;
66 std::filesystem::path core_log_path;
67 std::filesystem::path client_log_path;
68 std::filesystem::path validation_log_path;
69 std::filesystem::path events_ndjson_path;
70 std::string client_name;
71 std::string client_version;
72 std::string engine_name;
73 std::string engine_version;
79 bool initialized =
false;
83 SteadyClock::time_point start_steady = SteadyClock::now();
84 std::shared_ptr<ConsoleSink> console;
85 std::shared_ptr<TextFileSink> session_sink;
86 std::shared_ptr<TextFileSink> core_sink;
87 std::shared_ptr<TextFileSink> client_sink;
88 std::shared_ptr<TextFileSink> validation_sink;
89 std::shared_ptr<NdjsonSink> ndjson;
90 std::unordered_map<std::string, std::shared_ptr<log::Logger>> loggers;
94[[nodiscard]] std::shared_ptr<log::Logger> GetOrCreateLogger(
LoggingState& state, std::string_view name);
96[[nodiscard]] std::string EscapeJson(std::string_view value);
97[[nodiscard]] std::string JsonString(std::string_view value);
98[[nodiscard]] std::string JsonPath(
const std::filesystem::path& path);
99[[nodiscard]] std::string JsonOptionalString(
const std::string& value);
100[[nodiscard]] std::string FormatIso8601(SystemClock::time_point time_point);
101[[nodiscard]] std::string FormatElapsed(SteadyClock::duration duration);
102[[nodiscard]] std::string ThreadIdToString();
103[[nodiscard]]
bool StartsWith(std::string_view value, std::string_view prefix);
104[[nodiscard]] std::string FormatTextRecord(
const log::LogRecord& record);
105[[nodiscard]] std::string FormatNdjsonRecord(
const log::LogRecord& record);
108[[nodiscard]]
bool EnsureDirectoryExists(
const std::filesystem::path& path);
109[[nodiscard]]
log::LogRecord BuildRecord(
const LoggingState& state, std::string_view logger_name, log::Level level, std::string message);
111void EmitRecord(
const log::LogRecord& record,
const std::shared_ptr<ConsoleSink>& console_sink,
112 const std::shared_ptr<TextFileSink>& session_sink,
const std::shared_ptr<TextFileSink>& core_sink,
113 const std::shared_ptr<TextFileSink>& client_sink,
const std::shared_ptr<TextFileSink>& validation_sink,
114 const std::shared_ptr<NdjsonSink>& ndjson);
Definition log_internal.h:21
Definition log_paths.h:11
Definition log_internal.h:77