33namespace fs = std::filesystem;
50 fs::path m_path_dir_log;
51 fs::path m_path_file_parent;
52 fs::path m_path_file_child;
53 fs::path m_path_file_grand;
58 explicit Logs(fs::path
const& path_dir_log);
60 [[maybe_unused]] fs::path
const& get_path_dir_log()
const {
return m_path_dir_log; }
61 [[maybe_unused]] fs::path
const& get_path_file_parent()
const {
return m_path_file_parent; }
62 [[maybe_unused]] fs::path
const& get_path_file_child()
const {
return m_path_file_child; }
63 [[maybe_unused]] fs::path
const& get_path_file_grand()
const {
return m_path_file_grand; }
74 , m_path_file_parent()
84inline Logs::Logs(fs::path
const& path_dir_log)
85 : m_path_dir_log(path_dir_log)
86 , m_path_file_parent(path_dir_log /
"daemon.log")
87 , m_path_file_child(path_dir_log /
"{}" /
"child.log")
88 , m_path_file_grand(path_dir_log /
"{}" /
"grand.log")
90 fs::create_directories(m_path_file_parent.parent_path());
102 return_if(str_raw_json.empty(), Error(
"D::Empty json data"));
106 fs::path path_dir_log = Pop(db(
"path_dir_log").
template value<std::string>());
108 Logs logs(path_dir_log);
110 logs.m_path_file_parent = Pop(db(
"path_file_parent").
template value<std::string>());
111 logs.m_path_file_child = Pop(db(
"path_file_child").
template value<std::string>());
112 logs.m_path_file_grand = Pop(db(
"path_file_grand").
template value<std::string>());
125 db(
"path_dir_log") = logs.m_path_dir_log.string();
126 db(
"path_file_parent") = logs.m_path_file_parent.string();
127 db(
"path_file_child") = logs.m_path_file_child.string();
128 db(
"path_file_grand") = logs.m_path_file_grand.string();
136ENUM(Mode, HOST, GUEST);
142 pid_t m_pid_reference;
143 fs::path m_path_bin_daemon;
144 fs::path path_fifo_listen;
149 Daemon(Mode mode, fs::path
const& path_bin_daemon, fs::path
const& path_dir_fifo);
151 [[maybe_unused]] pid_t get_pid_reference()
const {
return m_pid_reference; }
152 [[maybe_unused]] fs::path
const& get_path_bin_daemon()
const {
return m_path_bin_daemon; }
153 [[maybe_unused]] fs::path
const& get_path_fifo_listen()
const {
return path_fifo_listen; }
154 [[maybe_unused]] Mode get_mode()
const {
return m_mode; }
163inline Daemon::Daemon()
166 , m_path_bin_daemon()
173inline Daemon::Daemon(Mode mode, fs::path
const& path_bin_daemon, fs::path
const& path_dir_fifo)
175 , m_pid_reference(getpid())
176 , m_path_bin_daemon(path_bin_daemon)
177 , path_fifo_listen(path_dir_fifo /
"daemon" / std::format(
"{}.fifo", m_mode.lower()))
189 return_if(str_raw_json.empty(), Error(
"D::Empty json data"));
193 std::string pid_reference = Pop(db(
"pid_reference").
template value<std::string>());
194 daemon.m_pid_reference = Try(std::stoi(pid_reference));
196 daemon.m_path_bin_daemon = Pop(db(
"path_bin_daemon").
template value<std::string>());
198 daemon.path_fifo_listen = Pop(db(
"path_fifo_listen").
template value<std::string>());
200 daemon.m_mode = Pop(Mode::from_string(Pop(db(
"mode").
template value<std::string>())));
213 db(
"pid_reference") = std::to_string(daemon.m_pid_reference);
214 db(
"path_bin_daemon") = daemon.m_path_bin_daemon.string();
215 db(
"path_fifo_listen") = daemon.path_fifo_listen.string();
216 db(
"mode") = std::string(daemon.m_mode);
A type-safe wrapper around nlohmann::json for database operations.
friend Value< std::string > serialize(Daemon const &daemon) noexcept
Serializes a Daemon class into a json string.
friend Value< Daemon > deserialize(std::string_view str_raw_json) noexcept
Deserializes JSON string into a Binds object.
friend Value< Logs > deserialize(std::string_view str_raw_json) noexcept
Deserializes JSON string into a Binds object.
friend Value< std::string > serialize(Logs const &logs) noexcept
Serializes a Logs class into a json string.
A database that interfaces with nlohmann json.
Custom enumeration class.
Enhanced error handling framework built on std::expected.
Value< Logs > deserialize(std::string_view str_raw_json) noexcept
Deserializes a json string into a Logs class.
Value< std::string > serialize(Logs const &logs) noexcept
Serializes a Logs class into a json string.
Portal daemon configuration and management.
Value< std::string > serialize(Daemon const &daemon) noexcept
Serializes a Daemon class into a json string.
Value< Daemon > deserialize(std::string_view str_raw_json) noexcept
Deserializes a json string into a Daemon class.
Value< Db > from_string(S &&s)
Parses a JSON string and creates a Db object.
Multi-level logging system with file and stdout sinks.
Enhanced expected type with integrated logging capabilities.