diff --git a/repertory/librepertory/include/events/events.hpp b/repertory/librepertory/include/events/events.hpp index 2b3112f1..988acdd5 100644 --- a/repertory/librepertory/include/events/events.hpp +++ b/repertory/librepertory/include/events/events.hpp @@ -27,23 +27,16 @@ namespace repertory { // clang-format off -E_SIMPLE1(item_timeout, trace, - std::string, api_path, ap, E_FROM_STRING +//WINFSP +E_SIMPLE3(remote_winfsp_client_event, debug, + std::string, function, func, E_FROM_STRING, + std::string, api_path, ap, E_FROM_STRING, + packet::error_type, result, res, E_FROM_INT32 ); - -E_SIMPLE2(invalid_cache_size, warn, - std::uint64_t, cache_size, sz, E_FROM_UINT64, - std::uint64_t, by, by, E_FROM_UINT64 -); - -E_SIMPLE2(max_cache_size_reached, warn, - std::uint64_t, cache_size, sz, E_FROM_UINT64, - std::uint64_t, max_cache_size, max, E_FROM_UINT64 -); - -E_SIMPLE2(packet_client_timeout, error, - std::string, event_name, en, E_FROM_STRING, - std::string, message, msg, E_FROM_STRING +E_SIMPLE3(remote_winfsp_server_event, debug, + std::string, function, FUNC, E_FROM_STRING, + std::string, api_path, AP, E_FROM_STRING, + packet::error_type, result, RES, E_FROM_INT32 ); //FUSE @@ -62,24 +55,6 @@ E_SIMPLE3(remote_fuse_server_event, debug, std::string, api_path, ap, E_FROM_STRING, packet::error_type, result, res, E_FROM_INT32 ); - -//WINFSP -E_SIMPLE3(winfsp_event, debug, - std::string, function, func, E_FROM_STRING, - std::string, api_path, ap, E_FROM_STRING, - NTSTATUS, result, res, E_FROM_INT32 -); -E_SIMPLE(drive_stop_timed_out, info); -E_SIMPLE3(remote_winfsp_client_event, debug, - std::string, function, func, E_FROM_STRING, - std::string, api_path, ap, E_FROM_STRING, - packet::error_type, result, res, E_FROM_INT32 -); -E_SIMPLE3(remote_winfsp_server_event, debug, - std::string, function, FUNC, E_FROM_STRING, - std::string, api_path, AP, E_FROM_STRING, - packet::error_type, result, RES, E_FROM_INT32 -); // clang-format on } // namespace repertory diff --git a/repertory/librepertory/include/events/types/curl_error.hpp b/repertory/librepertory/include/events/types/curl_error.hpp index e7316113..6d6a547e 100644 --- a/repertory/librepertory/include/events/types/curl_error.hpp +++ b/repertory/librepertory/include/events/types/curl_error.hpp @@ -33,6 +33,7 @@ struct curl_error final : public i_event { function_name(std::string{function_name_}), url(std::move(url_)) {} + static constexpr const event_level level{event_level::error}; static constexpr const std::string_view name{"curl_error"}; CURLcode code{}; @@ -40,7 +41,7 @@ struct curl_error final : public i_event { std::string url; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::error; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/debug_log.hpp b/repertory/librepertory/include/events/types/debug_log.hpp index 3f385e90..a5a29da7 100644 --- a/repertory/librepertory/include/events/types/debug_log.hpp +++ b/repertory/librepertory/include/events/types/debug_log.hpp @@ -31,13 +31,14 @@ struct debug_log final : public i_event { debug_log(std::string_view function_name_, std::string msg_) : function_name(std::string(function_name_)), msg(std::move(msg_)) {} + static constexpr const event_level level{event_level::debug}; static constexpr const std::string_view name{"debug_log"}; std::string function_name; std::string msg; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/directory_remove_failed.hpp b/repertory/librepertory/include/events/types/directory_remove_failed.hpp index 113cd01f..b79316e2 100644 --- a/repertory/librepertory/include/events/types/directory_remove_failed.hpp +++ b/repertory/librepertory/include/events/types/directory_remove_failed.hpp @@ -34,6 +34,7 @@ struct directory_remove_failed final : public i_event { error(error_), function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::error}; static constexpr const std::string_view name{"directory_remove_failed"}; std::string api_path; @@ -41,7 +42,7 @@ struct directory_remove_failed final : public i_event { std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::error; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/directory_removed.hpp b/repertory/librepertory/include/events/types/directory_removed.hpp index 607738ce..862d87fa 100644 --- a/repertory/librepertory/include/events/types/directory_removed.hpp +++ b/repertory/librepertory/include/events/types/directory_removed.hpp @@ -32,13 +32,14 @@ struct directory_removed final : public i_event { : api_path(std::move(api_path_)), function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::debug}; static constexpr const std::string_view name{"directory_removed"}; std::string api_path; std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/directory_removed_externally.hpp b/repertory/librepertory/include/events/types/directory_removed_externally.hpp index b3ccb4b2..483e376d 100644 --- a/repertory/librepertory/include/events/types/directory_removed_externally.hpp +++ b/repertory/librepertory/include/events/types/directory_removed_externally.hpp @@ -35,6 +35,7 @@ struct directory_removed_externally final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::warn}; static constexpr const std::string_view name{"directory_removed_externally"}; std::string api_path; @@ -42,7 +43,7 @@ struct directory_removed_externally final : public i_event { std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::warn; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/download_begin.hpp b/repertory/librepertory/include/events/types/download_begin.hpp index 1f2a1a4e..26be0adf 100644 --- a/repertory/librepertory/include/events/types/download_begin.hpp +++ b/repertory/librepertory/include/events/types/download_begin.hpp @@ -34,6 +34,7 @@ struct download_begin final : public i_event { dest_path(std::move(dest_path_)), function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"download_begin"}; std::string api_path; @@ -41,7 +42,7 @@ struct download_begin final : public i_event { std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/download_end.hpp b/repertory/librepertory/include/events/types/download_end.hpp index d202a426..ac74e33e 100644 --- a/repertory/librepertory/include/events/types/download_end.hpp +++ b/repertory/librepertory/include/events/types/download_end.hpp @@ -35,6 +35,7 @@ struct download_end final : public i_event { error(error_), function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"download_end"}; std::string api_path; @@ -43,7 +44,7 @@ struct download_end final : public i_event { std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/download_progress.hpp b/repertory/librepertory/include/events/types/download_progress.hpp index 37f776b3..289cf6fb 100644 --- a/repertory/librepertory/include/events/types/download_progress.hpp +++ b/repertory/librepertory/include/events/types/download_progress.hpp @@ -35,6 +35,7 @@ struct download_progress final : public i_event { function_name(std::string(function_name_)), progress(progress_) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"download_progress"}; std::string api_path; @@ -43,7 +44,7 @@ struct download_progress final : public i_event { double progress{}; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/download_restore_failed.hpp b/repertory/librepertory/include/events/types/download_restore_failed.hpp index 348ff1fe..f75b6b59 100644 --- a/repertory/librepertory/include/events/types/download_restore_failed.hpp +++ b/repertory/librepertory/include/events/types/download_restore_failed.hpp @@ -35,6 +35,7 @@ struct download_restore_failed final : public i_event { error(std::move(error_)), function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::error}; static constexpr const std::string_view name{"download_restore_failed"}; std::string api_path; @@ -43,7 +44,7 @@ struct download_restore_failed final : public i_event { std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::error; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/download_restored.hpp b/repertory/librepertory/include/events/types/download_restored.hpp index caba2765..cfe17445 100644 --- a/repertory/librepertory/include/events/types/download_restored.hpp +++ b/repertory/librepertory/include/events/types/download_restored.hpp @@ -34,6 +34,7 @@ struct download_restored final : public i_event { dest_path(std::move(dest_path_)), function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"download_restored"}; std::string api_path; @@ -41,7 +42,7 @@ struct download_restored final : public i_event { std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/download_resume_add_failed.hpp b/repertory/librepertory/include/events/types/download_resume_add_failed.hpp index 9842ec19..6c044109 100644 --- a/repertory/librepertory/include/events/types/download_resume_add_failed.hpp +++ b/repertory/librepertory/include/events/types/download_resume_add_failed.hpp @@ -36,6 +36,7 @@ struct download_resume_add_failed final : public i_event { error(std::move(error_)), function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::error}; static constexpr const std::string_view name{"download_resume_add_failed"}; std::string api_path; @@ -44,7 +45,7 @@ struct download_resume_add_failed final : public i_event { std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::error; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/download_resume_added.hpp b/repertory/librepertory/include/events/types/download_resume_added.hpp index 30b30bfc..054e3f1e 100644 --- a/repertory/librepertory/include/events/types/download_resume_added.hpp +++ b/repertory/librepertory/include/events/types/download_resume_added.hpp @@ -34,6 +34,7 @@ struct download_resume_added final : public i_event { dest_path(std::move(dest_path_)), function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::debug}; static constexpr const std::string_view name{"download_resume_added"}; std::string api_path; @@ -41,7 +42,7 @@ struct download_resume_added final : public i_event { std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/download_resume_removed.hpp b/repertory/librepertory/include/events/types/download_resume_removed.hpp index 873b21be..f90f2df1 100644 --- a/repertory/librepertory/include/events/types/download_resume_removed.hpp +++ b/repertory/librepertory/include/events/types/download_resume_removed.hpp @@ -34,6 +34,7 @@ struct download_resume_removed final : public i_event { dest_path(std::move(dest_path_)), function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::debug}; static constexpr const std::string_view name{"download_resume_removed"}; std::string api_path; @@ -41,7 +42,7 @@ struct download_resume_removed final : public i_event { std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/download_type_selected.hpp b/repertory/librepertory/include/events/types/download_type_selected.hpp index b1811c66..56cad897 100644 --- a/repertory/librepertory/include/events/types/download_type_selected.hpp +++ b/repertory/librepertory/include/events/types/download_type_selected.hpp @@ -35,6 +35,7 @@ struct download_type_selected final : public i_event { function_name(std::string(function_name_)), type(type_) {} + static constexpr const event_level level{event_level::debug}; static constexpr const std::string_view name{"download_type_selected"}; std::string api_path; @@ -43,7 +44,7 @@ struct download_type_selected final : public i_event { download_type type{}; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/drive_mount_failed.hpp b/repertory/librepertory/include/events/types/drive_mount_failed.hpp index 558c503d..416e3834 100644 --- a/repertory/librepertory/include/events/types/drive_mount_failed.hpp +++ b/repertory/librepertory/include/events/types/drive_mount_failed.hpp @@ -35,6 +35,7 @@ struct drive_mount_failed final : public i_event { mount_location(std::move(mount_location_)), status(status_) {} + static constexpr const event_level level{event_level::error}; static constexpr const std::string_view name{"drive_mount_failed"}; std::string function_name; @@ -42,7 +43,7 @@ struct drive_mount_failed final : public i_event { NTSTATUS status{}; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::error; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/drive_mount_result.hpp b/repertory/librepertory/include/events/types/drive_mount_result.hpp index 5077e68e..5c240d77 100644 --- a/repertory/librepertory/include/events/types/drive_mount_result.hpp +++ b/repertory/librepertory/include/events/types/drive_mount_result.hpp @@ -34,6 +34,7 @@ struct drive_mount_result final : public i_event { mount_location(std::move(mount_location_)), result(std::move(result_)) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"drive_mount_result"}; std::string function_name; @@ -41,7 +42,7 @@ struct drive_mount_result final : public i_event { std::string result; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/drive_mounted.hpp b/repertory/librepertory/include/events/types/drive_mounted.hpp index 874f58f4..44b5a157 100644 --- a/repertory/librepertory/include/events/types/drive_mounted.hpp +++ b/repertory/librepertory/include/events/types/drive_mounted.hpp @@ -32,13 +32,14 @@ struct drive_mounted final : public i_event { : function_name(std::string(function_name_)), mount_location(std::move(mount_location_)) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"drive_mounted"}; std::string function_name; std::string mount_location; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/drive_stop_timed_out.hpp b/repertory/librepertory/include/events/types/drive_stop_timed_out.hpp new file mode 100644 index 00000000..fb50eb62 --- /dev/null +++ b/repertory/librepertory/include/events/types/drive_stop_timed_out.hpp @@ -0,0 +1,67 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_STOP_TIMED_OUT_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_STOP_TIMED_OUT_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct drive_stop_timed_out final : public i_event { + drive_stop_timed_out() = default; + drive_stop_timed_out(std::string_view function_name_) + : function_name(std::string(function_name_)) {} + + static constexpr const event_level level{event_level::warn}; + static constexpr const std::string_view name{"drive_stop_timed_out"}; + + std::string function_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return level; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}", name, function_name); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::drive_stop_timed_out &value) { + data["function_name"] = value.function_name; + } + + static void from_json(const json &data, + repertory::drive_stop_timed_out &value) { + data.at("function_name").get_to(value.function_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_DRIVE_STOP_TIMED_OUT_HPP_ diff --git a/repertory/librepertory/include/events/types/drive_unmount_pending.hpp b/repertory/librepertory/include/events/types/drive_unmount_pending.hpp index e7eac508..f0d0c82b 100644 --- a/repertory/librepertory/include/events/types/drive_unmount_pending.hpp +++ b/repertory/librepertory/include/events/types/drive_unmount_pending.hpp @@ -33,13 +33,14 @@ struct drive_unmount_pending final : public i_event { : function_name(std::string(function_name_)), mount_location(std::move(mount_location_)) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"drive_unmount_pending"}; std::string function_name; std::string mount_location; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/drive_unmounted.hpp b/repertory/librepertory/include/events/types/drive_unmounted.hpp index 84a72f47..8ae128a3 100644 --- a/repertory/librepertory/include/events/types/drive_unmounted.hpp +++ b/repertory/librepertory/include/events/types/drive_unmounted.hpp @@ -32,13 +32,14 @@ struct drive_unmounted final : public i_event { : function_name(std::string(function_name_)), mount_location(std::move(mount_location_)) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"drive_unmounted"}; std::string function_name; std::string mount_location; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/event_level_changed.hpp b/repertory/librepertory/include/events/types/event_level_changed.hpp index 389c8ba8..4ebac75e 100644 --- a/repertory/librepertory/include/events/types/event_level_changed.hpp +++ b/repertory/librepertory/include/events/types/event_level_changed.hpp @@ -28,16 +28,17 @@ namespace repertory { struct event_level_changed final : public i_event { event_level_changed() = default; - event_level_changed(std::string_view function_name_, event_level level_) - : function_name(std::string(function_name_)), level(level_) {} + event_level_changed(std::string_view function_name_, event_level new_level_) + : function_name(std::string(function_name_)), new_level(new_level_) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"event_level_changed"}; std::string function_name; - event_level level{}; + event_level new_level{}; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { @@ -46,7 +47,7 @@ struct event_level_changed final : public i_event { [[nodiscard]] auto get_single_line() const -> std::string override { return fmt::format("{}|func|{}|level|{}", name, function_name, - event_level_to_string(level)); + event_level_to_string(new_level)); } }; } // namespace repertory @@ -54,14 +55,14 @@ struct event_level_changed final : public i_event { NLOHMANN_JSON_NAMESPACE_BEGIN template <> struct adl_serializer { static void to_json(json &data, const repertory::event_level_changed &value) { - data["event_level"] = repertory::event_level_to_string(value.level); + data["new_level"] = repertory::event_level_to_string(value.new_level); data["function_name"] = value.function_name; } static void from_json(const json &data, repertory::event_level_changed &value) { - value.level = repertory::event_level_from_string( - data.at("event_level").get()); + value.new_level = repertory::event_level_from_string( + data.at("new_level").get()); data.at("function_name").get_to(value.function_name); } }; diff --git a/repertory/librepertory/include/events/types/file_pinned.hpp b/repertory/librepertory/include/events/types/file_pinned.hpp index e3c670f0..5551c54d 100644 --- a/repertory/librepertory/include/events/types/file_pinned.hpp +++ b/repertory/librepertory/include/events/types/file_pinned.hpp @@ -32,13 +32,14 @@ struct file_pinned final : public i_event { : api_path(std::move(api_path_)), function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"file_pinned"}; std::string api_path; std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/file_remove_failed.hpp b/repertory/librepertory/include/events/types/file_remove_failed.hpp index e354c39f..ecf7a8c7 100644 --- a/repertory/librepertory/include/events/types/file_remove_failed.hpp +++ b/repertory/librepertory/include/events/types/file_remove_failed.hpp @@ -34,6 +34,7 @@ struct file_remove_failed final : public i_event { error(error_), function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::error}; static constexpr const std::string_view name{"file_remove_failed"}; std::string api_path; @@ -41,7 +42,7 @@ struct file_remove_failed final : public i_event { std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::error; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/file_removed.hpp b/repertory/librepertory/include/events/types/file_removed.hpp index 8479e258..081587ae 100644 --- a/repertory/librepertory/include/events/types/file_removed.hpp +++ b/repertory/librepertory/include/events/types/file_removed.hpp @@ -32,13 +32,14 @@ struct file_removed final : public i_event { : api_path(std::move(api_path_)), function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::debug}; static constexpr const std::string_view name{"file_removed"}; std::string api_path; std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/file_removed_externally.hpp b/repertory/librepertory/include/events/types/file_removed_externally.hpp index ff880331..854f927c 100644 --- a/repertory/librepertory/include/events/types/file_removed_externally.hpp +++ b/repertory/librepertory/include/events/types/file_removed_externally.hpp @@ -35,6 +35,7 @@ struct file_removed_externally final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::warn}; static constexpr const std::string_view name{"file_removed_externally"}; std::string api_path; @@ -42,7 +43,7 @@ struct file_removed_externally final : public i_event { std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::warn; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/file_unpinned.hpp b/repertory/librepertory/include/events/types/file_unpinned.hpp index ff26b05c..2675a805 100644 --- a/repertory/librepertory/include/events/types/file_unpinned.hpp +++ b/repertory/librepertory/include/events/types/file_unpinned.hpp @@ -32,13 +32,14 @@ struct file_unpinned final : public i_event { : api_path(std::move(api_path_)), function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"file_unpinned"}; std::string api_path; std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/file_upload_completed.hpp b/repertory/librepertory/include/events/types/file_upload_completed.hpp index 6cca9e50..2e8fb101 100644 --- a/repertory/librepertory/include/events/types/file_upload_completed.hpp +++ b/repertory/librepertory/include/events/types/file_upload_completed.hpp @@ -37,6 +37,7 @@ struct file_upload_completed final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"file_upload_completed"}; std::string api_path; @@ -46,7 +47,7 @@ struct file_upload_completed final : public i_event { std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/file_upload_failed.hpp b/repertory/librepertory/include/events/types/file_upload_failed.hpp index df4ecb71..d7232f5b 100644 --- a/repertory/librepertory/include/events/types/file_upload_failed.hpp +++ b/repertory/librepertory/include/events/types/file_upload_failed.hpp @@ -35,6 +35,7 @@ struct file_upload_failed final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::warn}; static constexpr const std::string_view name{"file_upload_failed"}; std::string api_path; @@ -43,7 +44,7 @@ struct file_upload_failed final : public i_event { std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::warn; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/file_upload_not_found.hpp b/repertory/librepertory/include/events/types/file_upload_not_found.hpp index 0ea39f6d..90c42ed4 100644 --- a/repertory/librepertory/include/events/types/file_upload_not_found.hpp +++ b/repertory/librepertory/include/events/types/file_upload_not_found.hpp @@ -34,6 +34,7 @@ struct file_upload_not_found final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::warn}; static constexpr const std::string_view name{"file_upload_not_found"}; std::string api_path; @@ -41,7 +42,7 @@ struct file_upload_not_found final : public i_event { std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::warn; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/file_upload_queued.hpp b/repertory/librepertory/include/events/types/file_upload_queued.hpp index 504d734f..efa3adae 100644 --- a/repertory/librepertory/include/events/types/file_upload_queued.hpp +++ b/repertory/librepertory/include/events/types/file_upload_queued.hpp @@ -34,6 +34,7 @@ struct file_upload_queued final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"file_upload_queued"}; std::string api_path; @@ -41,7 +42,7 @@ struct file_upload_queued final : public i_event { std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/file_upload_removed.hpp b/repertory/librepertory/include/events/types/file_upload_removed.hpp index 9a094cda..e1b60dfd 100644 --- a/repertory/librepertory/include/events/types/file_upload_removed.hpp +++ b/repertory/librepertory/include/events/types/file_upload_removed.hpp @@ -32,13 +32,14 @@ struct file_upload_removed final : public i_event { : api_path(std::move(api_path_)), function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::debug}; static constexpr const std::string_view name{"file_upload_removed"}; std::string api_path; std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/file_upload_retry.hpp b/repertory/librepertory/include/events/types/file_upload_retry.hpp index 3aa19744..fed85d67 100644 --- a/repertory/librepertory/include/events/types/file_upload_retry.hpp +++ b/repertory/librepertory/include/events/types/file_upload_retry.hpp @@ -35,6 +35,7 @@ struct file_upload_retry final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::warn}; static constexpr const std::string_view name{"file_upload_retry"}; std::string api_path; @@ -43,7 +44,7 @@ struct file_upload_retry final : public i_event { std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::warn; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/filesystem_item_added.hpp b/repertory/librepertory/include/events/types/filesystem_item_added.hpp index f9521a09..1b77df57 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_added.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_added.hpp @@ -35,6 +35,7 @@ struct filesystem_item_added final : public i_event { directory(directory_), function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::debug}; static constexpr const std::string_view name{"filesystem_item_added"}; std::string api_parent; @@ -43,7 +44,7 @@ struct filesystem_item_added final : public i_event { std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/filesystem_item_closed.hpp b/repertory/librepertory/include/events/types/filesystem_item_closed.hpp index 3871ef9f..22083891 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_closed.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_closed.hpp @@ -37,6 +37,7 @@ struct filesystem_item_closed final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::trace}; static constexpr const std::string_view name{"filesystem_item_closed"}; std::string api_path; @@ -46,7 +47,7 @@ struct filesystem_item_closed final : public i_event { std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::trace; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/filesystem_item_evicted.hpp b/repertory/librepertory/include/events/types/filesystem_item_evicted.hpp index ccf100f5..c58bbace 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_evicted.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_evicted.hpp @@ -35,6 +35,7 @@ struct filesystem_item_evicted final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::debug}; static constexpr const std::string_view name{"filesystem_item_evicted"}; std::string api_path; @@ -42,7 +43,7 @@ struct filesystem_item_evicted final : public i_event { std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp b/repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp index 61362854..8930b19b 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp @@ -39,6 +39,7 @@ struct filesystem_item_handle_closed final : public i_event { handle(handle_), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::trace}; static constexpr const std::string_view name{"filesystem_item_handle_closed"}; std::string api_path; @@ -49,7 +50,7 @@ struct filesystem_item_handle_closed final : public i_event { std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::trace; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp b/repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp index 86016223..e61d6539 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp @@ -37,6 +37,7 @@ struct filesystem_item_handle_opened final : public i_event { handle(handle_), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::trace}; static constexpr const std::string_view name{"filesystem_item_handle_opened"}; std::string api_path; @@ -46,7 +47,7 @@ struct filesystem_item_handle_opened final : public i_event { std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::trace; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/filesystem_item_opened.hpp b/repertory/librepertory/include/events/types/filesystem_item_opened.hpp index 4a151db6..b9f508d4 100644 --- a/repertory/librepertory/include/events/types/filesystem_item_opened.hpp +++ b/repertory/librepertory/include/events/types/filesystem_item_opened.hpp @@ -36,6 +36,7 @@ struct filesystem_item_opened final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::trace}; static constexpr const std::string_view name{"filesystem_item_opened"}; std::string api_path; @@ -44,7 +45,7 @@ struct filesystem_item_opened final : public i_event { std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::trace; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/invalid_cache_size.hpp b/repertory/librepertory/include/events/types/invalid_cache_size.hpp new file mode 100644 index 00000000..f47e1adb --- /dev/null +++ b/repertory/librepertory/include/events/types/invalid_cache_size.hpp @@ -0,0 +1,76 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_INVALID_CACHE_SIZE_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_INVALID_CACHE_SIZE_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct invalid_cache_size final : public i_event { + invalid_cache_size() = default; + invalid_cache_size(std::uint64_t cache_size_, std::string_view function_name_, + std::uint64_t invalid_size_) + : cache_size(cache_size_), + function_name(std::string{function_name_}), + invalid_size(invalid_size_) {} + + static constexpr const event_level level{event_level::warn}; + static constexpr const std::string_view name{"invalid_cache_size"}; + + std::uint64_t cache_size{}; + std::string function_name; + std::uint64_t invalid_size{}; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return level; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|size|{}|by|{}", name, function_name, + cache_size, invalid_size); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::invalid_cache_size &value) { + data["cache_size"] = value.cache_size; + data["function_name"] = value.function_name; + data["invalid_size"] = value.invalid_size; + } + + static void from_json(const json &data, + repertory::invalid_cache_size &value) { + data.at("cache_size").get_to(value.cache_size); + data.at("function_name").get_to(value.function_name); + data.at("invalid_size").get_to(value.invalid_size); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_INVALID_CACHE_SIZE_HPP_ diff --git a/repertory/librepertory/include/events/types/item_timeout.hpp b/repertory/librepertory/include/events/types/item_timeout.hpp new file mode 100644 index 00000000..f477e90b --- /dev/null +++ b/repertory/librepertory/include/events/types/item_timeout.hpp @@ -0,0 +1,69 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_ITEM_TIMEOUT_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_ITEM_TIMEOUT_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct item_timeout final : public i_event { + item_timeout() = default; + item_timeout(std::string api_path_, std::string_view function_name_) + : api_path(std::move(api_path_)), + function_name(std::string(function_name_)) {} + + static constexpr const event_level level{event_level::trace}; + static constexpr const std::string_view name{"item_timeout"}; + + std::string api_path; + std::string function_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return level; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}", name, function_name, api_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::item_timeout &value) { + data["api_path"] = value.api_path; + data["function_name"] = value.function_name; + } + + static void from_json(const json &data, repertory::item_timeout &value) { + data.at("api_path").get_to(value.api_path); + data.at("function_name").get_to(value.function_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_ITEM_TIMEOUT_HPP_ diff --git a/repertory/librepertory/include/events/types/max_cache_size_reached.hpp b/repertory/librepertory/include/events/types/max_cache_size_reached.hpp new file mode 100644 index 00000000..55d68dd3 --- /dev/null +++ b/repertory/librepertory/include/events/types/max_cache_size_reached.hpp @@ -0,0 +1,78 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_MAX_CACHE_SIZE_REACHED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_MAX_CACHE_SIZE_REACHED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct max_cache_size_reached final : public i_event { + max_cache_size_reached() = default; + max_cache_size_reached(std::uint64_t cache_size_, + std::string_view function_name_, + std::uint64_t max_cache_size_) + : cache_size(cache_size_), + function_name(std::string{function_name_}), + max_cache_size(max_cache_size_) {} + + static constexpr const event_level level{event_level::warn}; + static constexpr const std::string_view name{"max_cache_size_reached"}; + + std::uint64_t cache_size{}; + std::string function_name; + std::uint64_t max_cache_size{}; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return level; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|size|{}|max|{}", name, function_name, + cache_size, max_cache_size); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::max_cache_size_reached &value) { + data["cache_size"] = value.cache_size; + data["function_name"] = value.function_name; + data["max_cache_size"] = value.max_cache_size; + } + + static void from_json(const json &data, + repertory::max_cache_size_reached &value) { + data.at("cache_size").get_to(value.cache_size); + data.at("function_name").get_to(value.function_name); + data.at("max_cache_size").get_to(value.max_cache_size); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_MAX_CACHE_SIZE_REACHED_HPP_ diff --git a/repertory/librepertory/include/events/types/orphaned_file_detected.hpp b/repertory/librepertory/include/events/types/orphaned_file_detected.hpp index 55d9a9c9..99078f0b 100644 --- a/repertory/librepertory/include/events/types/orphaned_file_detected.hpp +++ b/repertory/librepertory/include/events/types/orphaned_file_detected.hpp @@ -33,13 +33,14 @@ struct orphaned_file_detected final : public i_event { : function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::warn}; static constexpr const std::string_view name{"orphaned_file_detected"}; std::string function_name; std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp b/repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp index ec6a7273..0ec43dff 100644 --- a/repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp +++ b/repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp @@ -36,8 +36,10 @@ struct orphaned_file_processing_failed final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::error}; static constexpr const std::string_view name{ - "orphaned_file_processing_failed"}; + "orphaned_file_processing_failed", + }; std::string dest_path; std::string error; @@ -45,7 +47,7 @@ struct orphaned_file_processing_failed final : public i_event { std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp b/repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp index a263d204..a51e6566 100644 --- a/repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp +++ b/repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp @@ -33,13 +33,14 @@ struct orphaned_source_file_detected final : public i_event { : function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::warn}; static constexpr const std::string_view name{"orphaned_source_file_detected"}; std::string function_name; std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp b/repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp index 9bdb4171..289a577f 100644 --- a/repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp +++ b/repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp @@ -33,13 +33,14 @@ struct orphaned_source_file_removed final : public i_event { : function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::warn}; static constexpr const std::string_view name{"orphaned_source_file_removed"}; std::string function_name; std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/packet_client_timeout.hpp b/repertory/librepertory/include/events/types/packet_client_timeout.hpp new file mode 100644 index 00000000..72596b60 --- /dev/null +++ b/repertory/librepertory/include/events/types/packet_client_timeout.hpp @@ -0,0 +1,77 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_PACKET_CLIENT_TIMEOUT_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_PACKET_CLIENT_TIMEOUT_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct packet_client_timeout final : public i_event { + packet_client_timeout() = default; + packet_client_timeout(std::string event_name_, + std::string_view function_name_, std::string msg_) + : event_name(std::move(event_name_)), + function_name(std::string(function_name_)), + msg(std::move(msg_)) {} + + static constexpr const event_level level{event_level::warn}; + static constexpr const std::string_view name{"packet_client_timeout"}; + + std::string event_name; + std::string function_name; + std::string msg; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return level; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|event|{}|msg|{}", name, function_name, + event_name, msg); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::packet_client_timeout &value) { + data["event_name"] = value.event_name; + data["function_name"] = value.function_name; + data["msg"] = value.msg; + } + + static void from_json(const json &data, + repertory::packet_client_timeout &value) { + data.at("event_name").get_to(value.event_name); + data.at("function_name").get_to(value.function_name); + data.at("msg").get_to(value.msg); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_PACKET_CLIENT_TIMEOUT_HPP_ diff --git a/repertory/librepertory/include/events/types/polling_item_begin.hpp b/repertory/librepertory/include/events/types/polling_item_begin.hpp index f7aa113c..e2ae2a9a 100644 --- a/repertory/librepertory/include/events/types/polling_item_begin.hpp +++ b/repertory/librepertory/include/events/types/polling_item_begin.hpp @@ -32,13 +32,14 @@ struct polling_item_begin final : public i_event { : function_name(std::string(function_name_)), item_name(std::move(item_name_)) {} + static constexpr const event_level level{event_level::debug}; static constexpr const std::string_view name{"polling_item_begin"}; std::string function_name; std::string item_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/polling_item_end.hpp b/repertory/librepertory/include/events/types/polling_item_end.hpp index 890d7ad8..3da7e18f 100644 --- a/repertory/librepertory/include/events/types/polling_item_end.hpp +++ b/repertory/librepertory/include/events/types/polling_item_end.hpp @@ -32,13 +32,14 @@ struct polling_item_end final : public i_event { : function_name(std::string(function_name_)), item_name(std::move(item_name_)) {} + static constexpr const event_level level{event_level::debug}; static constexpr const std::string_view name{"polling_item_end"}; std::string function_name; std::string item_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/provider_offline.hpp b/repertory/librepertory/include/events/types/provider_offline.hpp index abf012c9..d55a3e7c 100644 --- a/repertory/librepertory/include/events/types/provider_offline.hpp +++ b/repertory/librepertory/include/events/types/provider_offline.hpp @@ -34,6 +34,7 @@ struct provider_offline final : public i_event { host_name_or_ip(std::move(host_name_or_ip_)), port(port_) {} + static constexpr const event_level level{event_level::warn}; static constexpr const std::string_view name{"provider_offline"}; std::string function_name; @@ -41,7 +42,7 @@ struct provider_offline final : public i_event { std::uint16_t port{}; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/provider_upload_begin.hpp b/repertory/librepertory/include/events/types/provider_upload_begin.hpp index 7891005e..9042e0b3 100644 --- a/repertory/librepertory/include/events/types/provider_upload_begin.hpp +++ b/repertory/librepertory/include/events/types/provider_upload_begin.hpp @@ -34,6 +34,7 @@ struct provider_upload_begin final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"provider_upload_begin"}; std::string api_path; @@ -41,7 +42,7 @@ struct provider_upload_begin final : public i_event { std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::warn; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/provider_upload_end.hpp b/repertory/librepertory/include/events/types/provider_upload_end.hpp index ebab806f..3cee2a89 100644 --- a/repertory/librepertory/include/events/types/provider_upload_end.hpp +++ b/repertory/librepertory/include/events/types/provider_upload_end.hpp @@ -35,6 +35,7 @@ struct provider_upload_end final : public i_event { function_name(std::string(function_name_)), source_path(std::move(source_path_)) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"provider_upload_end"}; std::string api_path; @@ -43,7 +44,7 @@ struct provider_upload_end final : public i_event { std::string source_path; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/repertory_exception.hpp b/repertory/librepertory/include/events/types/repertory_exception.hpp index e8162e5a..8ffa1ecb 100644 --- a/repertory/librepertory/include/events/types/repertory_exception.hpp +++ b/repertory/librepertory/include/events/types/repertory_exception.hpp @@ -31,13 +31,14 @@ struct repertory_exception final : public i_event { repertory_exception(std::string_view function_name_, std::string msg_) : function_name(std::string(function_name_)), msg(std::move(msg_)) {} + static constexpr const event_level level{event_level::error}; static constexpr const std::string_view name{"repertory_exception"}; std::string function_name; std::string msg; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::error; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/service_start_begin.hpp b/repertory/librepertory/include/events/types/service_start_begin.hpp index fda80067..74022c3e 100644 --- a/repertory/librepertory/include/events/types/service_start_begin.hpp +++ b/repertory/librepertory/include/events/types/service_start_begin.hpp @@ -33,13 +33,14 @@ struct service_start_begin final : public i_event { : function_name(std::string(function_name_)), service_name(std::move(service_name_)) {} + static constexpr const event_level level{event_level::debug}; static constexpr const std::string_view name{"service_start_begin"}; std::string function_name; std::string service_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/service_start_end.hpp b/repertory/librepertory/include/events/types/service_start_end.hpp index 4eaa422f..7e9c2633 100644 --- a/repertory/librepertory/include/events/types/service_start_end.hpp +++ b/repertory/librepertory/include/events/types/service_start_end.hpp @@ -32,13 +32,14 @@ struct service_start_end final : public i_event { : function_name(std::string(function_name_)), service_name(std::move(service_name_)) {} + static constexpr const event_level level{event_level::debug}; static constexpr const std::string_view name{"service_start_end"}; std::string function_name; std::string service_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/service_stop_begin.hpp b/repertory/librepertory/include/events/types/service_stop_begin.hpp index c6aaa7da..829bfe38 100644 --- a/repertory/librepertory/include/events/types/service_stop_begin.hpp +++ b/repertory/librepertory/include/events/types/service_stop_begin.hpp @@ -32,13 +32,14 @@ struct service_stop_begin final : public i_event { : function_name(std::string(function_name_)), service_name(std::move(service_name_)) {} + static constexpr const event_level level{event_level::debug}; static constexpr const std::string_view name{"service_stop_begin"}; std::string function_name; std::string service_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/service_stop_end.hpp b/repertory/librepertory/include/events/types/service_stop_end.hpp index be127f36..be0b0611 100644 --- a/repertory/librepertory/include/events/types/service_stop_end.hpp +++ b/repertory/librepertory/include/events/types/service_stop_end.hpp @@ -32,13 +32,14 @@ struct service_stop_end final : public i_event { : function_name(std::string(function_name_)), service_name(std::move(service_name_)) {} + static constexpr const event_level level{event_level::debug}; static constexpr const std::string_view name{"service_stop_end"}; std::string function_name; std::string service_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::debug; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/unmount_requested.hpp b/repertory/librepertory/include/events/types/unmount_requested.hpp index a82a99fc..b1f274c8 100644 --- a/repertory/librepertory/include/events/types/unmount_requested.hpp +++ b/repertory/librepertory/include/events/types/unmount_requested.hpp @@ -31,12 +31,13 @@ struct unmount_requested final : public i_event { unmount_requested(std::string_view function_name_) : function_name(std::string(function_name_)) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"unmount_requested"}; std::string function_name; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/unmount_result.hpp b/repertory/librepertory/include/events/types/unmount_result.hpp index 1131933e..a08da22f 100644 --- a/repertory/librepertory/include/events/types/unmount_result.hpp +++ b/repertory/librepertory/include/events/types/unmount_result.hpp @@ -35,6 +35,7 @@ struct unmount_result final : public i_event { mount_location(std::move(mount_location_)), result(result_) {} + static constexpr const event_level level{event_level::info}; static constexpr const std::string_view name{"unmount_result"}; std::string function_name; @@ -42,7 +43,7 @@ struct unmount_result final : public i_event { std::int32_t result{}; [[nodiscard]] auto get_event_level() const -> event_level override { - return event_level::info; + return level; } [[nodiscard]] auto get_name() const -> std::string_view override { diff --git a/repertory/librepertory/include/events/types/winfsp_event.hpp b/repertory/librepertory/include/events/types/winfsp_event.hpp new file mode 100644 index 00000000..638e2ce3 --- /dev/null +++ b/repertory/librepertory/include/events/types/winfsp_event.hpp @@ -0,0 +1,77 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_WINFSP_EVENT_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_WINFSP_EVENT_HPP_ +#if defined(_WIN32) + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct winfsp_event final : public i_event { + winfsp_event() = default; + winfsp_event(std::string api_path_, NTSTATUS error_, + std::string_view function_name_) + : api_path(std::move(api_path_)), + error(error_), + function_name(std::string{function_name_}) {} + + static constexpr const event_level level{event_level::debug}; + static constexpr const std::string_view name{"winfsp_event"}; + + std::string api_path; + NTSTATUS error{}; + std::string function_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return level; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|error|{}", name, function_name, + api_path, error); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::winfsp_event &value) { + data["api_path"] = value.api_path; + data["error"] = value.error; + data["function_name"] = value.function_name; + } + + static void from_json(const json &data, repertory::winfsp_event &value) { + data.at("api_path").get_to(value.api_path); + data.at("error").get_to(value.error); + data.at("function_name").get_to(value.function_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // defined(_WIN32) +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_WINFSP_EVENT_HPP_ diff --git a/repertory/librepertory/src/comm/packet/packet_client.cpp b/repertory/librepertory/src/comm/packet/packet_client.cpp index 6848211b..8a6ca3a4 100644 --- a/repertory/librepertory/src/comm/packet/packet_client.cpp +++ b/repertory/librepertory/src/comm/packet/packet_client.cpp @@ -22,6 +22,7 @@ #include "comm/packet/packet_client.hpp" #include "events/event_system.hpp" +#include "events/types/packet_client_timeout.hpp" #include "platform/platform.hpp" #include "types/repertory.hpp" #include "utils/collection.hpp" @@ -105,8 +106,8 @@ void packet_client::put_client(std::shared_ptr &cli) { } } -auto packet_client::read_packet(client &cli, - packet &response) const -> packet::error_type { +auto packet_client::read_packet(client &cli, packet &response) const + -> packet::error_type { data_buffer buffer(sizeof(std::uint32_t)); const auto read_buffer = [&]() { std::uint32_t offset{}; @@ -147,8 +148,8 @@ void packet_client::resolve() { .resolve(cfg_.host_name_or_ip, std::to_string(cfg_.api_port)); } -auto packet_client::send(std::string_view method, - std::uint32_t &service_flags) -> packet::error_type { +auto packet_client::send(std::string_view method, std::uint32_t &service_flags) + -> packet::error_type { packet request; return send(method, request, service_flags); } @@ -160,8 +161,8 @@ auto packet_client::send(std::string_view method, packet &request, } auto packet_client::send(std::string_view method, packet &request, - packet &response, - std::uint32_t &service_flags) -> packet::error_type { + packet &response, std::uint32_t &service_flags) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto success = false; @@ -184,7 +185,7 @@ auto packet_client::send(std::string_view method, packet &request, timeout request_timeout( [method, current_client]() { event_system::instance().raise( - "request", std::string{method}); + "request", function_name, std::string{method}); packet_client::close(*current_client); }, std::chrono::milliseconds(cfg_.send_timeout_ms)); @@ -206,7 +207,7 @@ auto packet_client::send(std::string_view method, packet &request, timeout response_timeout( [method, current_client]() { event_system::instance().raise( - "response", std::string{method}); + "response", function_name, std::string{method}); packet_client::close(*current_client); }, std::chrono::milliseconds(cfg_.recv_timeout_ms)); diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp index 1e04ba2a..bb23664d 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp @@ -33,6 +33,7 @@ #include "events/event_system.hpp" #include "events/types/drive_mount_result.hpp" #include "events/types/drive_mounted.hpp" +#include "events/types/drive_stop_timed_out.hpp" #include "events/types/drive_unmount_pending.hpp" #include "events/types/drive_unmounted.hpp" #include "platform/platform.hpp" @@ -281,6 +282,7 @@ void fuse_drive::stop_all() { }); if (future.wait_for(30s) == std::future_status::timeout) { + event_system::instance().raise(function_name); app_config::set_stop_requested(); future.wait(); } @@ -294,7 +296,7 @@ void fuse_drive::destroy_impl(void *ptr) { REPERTORY_USES_FUNCTION_NAME(); event_system::instance().raise(function_name, - get_mount_location()); + get_mount_location()); stop_all(); @@ -303,7 +305,7 @@ void fuse_drive::destroy_impl(void *ptr) { fuse_base::destroy_impl(ptr); event_system::instance().raise(function_name, - get_mount_location()); + get_mount_location()); } auto fuse_drive::fallocate_impl(std::string /*api_path*/, int mode, @@ -617,7 +619,7 @@ void *fuse_drive::init_impl(struct fuse_conn_info *conn) { } event_system::instance().raise(function_name, - get_mount_location()); + get_mount_location()); } catch (const std::exception &e) { utils::error::raise_error(function_name, e, "exception during fuse init"); diff --git a/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp b/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp index d75e1ac4..84f91444 100644 --- a/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp +++ b/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp @@ -31,9 +31,11 @@ #include "events/types/drive_mount_failed.hpp" #include "events/types/drive_mount_result.hpp" #include "events/types/drive_mounted.hpp" +#include "events/types/drive_stop_timed_out.hpp" #include "events/types/drive_unmount_pending.hpp" #include "events/types/drive_unmounted.hpp" #include "events/types/unmount_requested.hpp" +#include "events/types/winfsp_event.hpp" #include "platform/platform.hpp" #include "providers/i_provider.hpp" #include "types/repertory.hpp" @@ -52,9 +54,9 @@ namespace repertory { #define RAISE_WINFSP_EVENT(func, file, ret) \ if (config_.get_enable_drive_events() && \ (((config_.get_event_level() >= winfsp_event::level) && \ - (ret != STATUS_SUCCESS)) || \ + ((ret) != STATUS_SUCCESS)) || \ (config_.get_event_level() >= event_level::trace))) \ - event_system::instance().raise(std::string{func}, file, ret) + event_system::instance().raise(file, func, ret) winfsp_drive::winfsp_service::winfsp_service( lock_data &lock, winfsp_drive &drive, std::vector drive_args, @@ -88,8 +90,8 @@ auto winfsp_drive::handle_error(std::string_view function_name, return ret; } -auto winfsp_drive::winfsp_service::OnStart(ULONG /*Argc*/, - PWSTR * /*Argv*/) -> NTSTATUS { +auto winfsp_drive::winfsp_service::OnStart(ULONG /*Argc*/, PWSTR * /*Argv*/) + -> NTSTATUS { REPERTORY_USES_FUNCTION_NAME(); auto mount_location = utils::string::to_lower( @@ -136,7 +138,7 @@ auto winfsp_drive::winfsp_service::OnStop() -> NTSTATUS { timeout stop_timeout( []() { - event_system::instance().raise(); + event_system::instance().raise(function_name); app_config::set_stop_requested(); }, 30s); @@ -468,9 +470,10 @@ auto winfsp_drive::get_item_meta(const std::string &api_path, return ret; } -auto winfsp_drive::get_security_by_name( - PWSTR file_name, PUINT32 attributes, PSECURITY_DESCRIPTOR descriptor, - std::uint64_t *descriptor_size) -> NTSTATUS { +auto winfsp_drive::get_security_by_name(PWSTR file_name, PUINT32 attributes, + PSECURITY_DESCRIPTOR descriptor, + std::uint64_t *descriptor_size) + -> NTSTATUS { auto api_path = utils::path::create_api_path(utils::string::to_utf8(file_name)); @@ -730,8 +733,8 @@ auto winfsp_drive::Open(PWSTR file_name, UINT32 create_options, auto winfsp_drive::Overwrite(PVOID /*file_node*/, PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes, - UINT64 /*allocation_size*/, - FileInfo *file_info) -> NTSTATUS { + UINT64 /*allocation_size*/, FileInfo *file_info) + -> NTSTATUS { REPERTORY_USES_FUNCTION_NAME(); std::string api_path; @@ -837,8 +840,8 @@ void winfsp_drive::populate_file_info(std::uint64_t file_size, } auto winfsp_drive::Read(PVOID /*file_node*/, PVOID file_desc, PVOID buffer, - UINT64 offset, ULONG length, - PULONG bytes_transferred) -> NTSTATUS { + UINT64 offset, ULONG length, PULONG bytes_transferred) + -> NTSTATUS { REPERTORY_USES_FUNCTION_NAME(); *bytes_transferred = 0U; @@ -893,8 +896,8 @@ auto winfsp_drive::Read(PVOID /*file_node*/, PVOID file_desc, PVOID buffer, auto winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc, PWSTR /*pattern*/, PWSTR marker, PVOID buffer, - ULONG buffer_length, - PULONG bytes_transferred) -> NTSTATUS { + ULONG buffer_length, PULONG bytes_transferred) + -> NTSTATUS { REPERTORY_USES_FUNCTION_NAME(); std::string api_path; @@ -1050,8 +1053,8 @@ auto winfsp_drive::Rename(PVOID /*file_node*/, PVOID /*file_desc*/, auto winfsp_drive::SetBasicInfo(PVOID /*file_node*/, PVOID file_desc, UINT32 attributes, UINT64 creation_time, UINT64 last_access_time, UINT64 last_write_time, - UINT64 change_time, - FileInfo *file_info) -> NTSTATUS { + UINT64 change_time, FileInfo *file_info) + -> NTSTATUS { REPERTORY_USES_FUNCTION_NAME(); std::string api_path; @@ -1195,6 +1198,7 @@ void winfsp_drive::stop_all() { }); if (future.wait_for(30s) == std::future_status::timeout) { + event_system::instance().raise(function_name); app_config::set_stop_requested(); future.wait(); } diff --git a/repertory/librepertory/src/events/consumers/console_consumer.cpp b/repertory/librepertory/src/events/consumers/console_consumer.cpp index 00075d9d..7663b2bb 100644 --- a/repertory/librepertory/src/events/consumers/console_consumer.cpp +++ b/repertory/librepertory/src/events/consumers/console_consumer.cpp @@ -64,7 +64,7 @@ console_consumer::console_consumer(event_level level) { E_SUBSCRIBE_ALL(process_event2); E_SUBSCRIBE_EXACT(event_level_changed, - [](auto &&event) { set_level(event.level); }); + [](auto &&event) { set_level(event.new_level); }); } console_consumer::~console_consumer() { E_CONSUMER_RELEASE(); } diff --git a/repertory/librepertory/src/events/consumers/logging_consumer.cpp b/repertory/librepertory/src/events/consumers/logging_consumer.cpp index ca85aa7f..97942a55 100644 --- a/repertory/librepertory/src/events/consumers/logging_consumer.cpp +++ b/repertory/librepertory/src/events/consumers/logging_consumer.cpp @@ -68,7 +68,7 @@ logging_consumer::logging_consumer(event_level level, E_SUBSCRIBE_ALL(process_event2); E_SUBSCRIBE_EXACT(event_level_changed, - [](auto &&event) { set_level(event.level); }); + [](auto &&event) { set_level(event.new_level); }); } logging_consumer::~logging_consumer() { E_CONSUMER_RELEASE(); } diff --git a/repertory/librepertory/src/file_manager/cache_size_mgr.cpp b/repertory/librepertory/src/file_manager/cache_size_mgr.cpp index 5ffa6d58..b661ecf7 100644 --- a/repertory/librepertory/src/file_manager/cache_size_mgr.cpp +++ b/repertory/librepertory/src/file_manager/cache_size_mgr.cpp @@ -23,6 +23,8 @@ #include "app_config.hpp" #include "events/event_system.hpp" +#include "events/types/invalid_cache_size.hpp" +#include "events/types/max_cache_size_reached.hpp" #include "types/startup_exception.hpp" #include "utils/file_utils.hpp" @@ -30,6 +32,8 @@ namespace repertory { cache_size_mgr cache_size_mgr::instance_{}; auto cache_size_mgr::expand(std::uint64_t size) -> api_error { + REPERTORY_USES_FUNCTION_NAME(); + unique_mutex_lock lock(mtx_); if (cfg_ == nullptr) { @@ -53,8 +57,8 @@ auto cache_size_mgr::expand(std::uint64_t size) -> api_error { while (not get_stop_requested() && cache_size_ > max_cache_size && cache_dir.count() > 1U) { if (last_cache_size != cache_size_) { - event_system::instance().raise(cache_size_, - max_cache_size); + event_system::instance().raise( + cache_size_, function_name, max_cache_size); last_cache_size = cache_size_; } notify_.wait_for(lock, cache_wait_secs); @@ -93,6 +97,8 @@ void cache_size_mgr::initialize(app_config *cfg) { } auto cache_size_mgr::shrink(std::uint64_t size) -> api_error { + REPERTORY_USES_FUNCTION_NAME(); + mutex_lock lock(mtx_); if (size == 0U) { notify_.notify_all(); @@ -102,7 +108,8 @@ auto cache_size_mgr::shrink(std::uint64_t size) -> api_error { if (cache_size_ >= size) { cache_size_ -= size; } else { - event_system::instance().raise(cache_size_, size); + event_system::instance().raise(cache_size_, + function_name, size); cache_size_ = 0U; } diff --git a/repertory/librepertory/src/file_manager/file_manager.cpp b/repertory/librepertory/src/file_manager/file_manager.cpp index 618a6a3c..207d6b42 100644 --- a/repertory/librepertory/src/file_manager/file_manager.cpp +++ b/repertory/librepertory/src/file_manager/file_manager.cpp @@ -35,6 +35,7 @@ #include "events/types/file_upload_removed.hpp" #include "events/types/file_upload_retry.hpp" #include "events/types/filesystem_item_evicted.hpp" +#include "events/types/item_timeout.hpp" #include "events/types/service_start_begin.hpp" #include "events/types/service_start_end.hpp" #include "events/types/service_stop_begin.hpp" @@ -106,6 +107,8 @@ auto file_manager::close_all(const std::string &api_path) -> bool { } void file_manager::close_timed_out_files() { + REPERTORY_USES_FUNCTION_NAME(); + unique_recur_mutex_lock file_lock(open_file_mtx_); auto closeable_list = std::accumulate(open_file_lookup_.begin(), open_file_lookup_.end(), @@ -124,8 +127,8 @@ void file_manager::close_timed_out_files() { for (auto &closeable_file : closeable_list) { closeable_file->close(); - event_system::instance().raise( - closeable_file->get_api_path()); + event_system::instance().raise(closeable_file->get_api_path(), + function_name); } closeable_list.clear(); } diff --git a/repertory/repertory_test/src/file_manager_test.cpp b/repertory/repertory_test/src/file_manager_test.cpp index 6f6d0d25..c7fad7cc 100644 --- a/repertory/repertory_test/src/file_manager_test.cpp +++ b/repertory/repertory_test/src/file_manager_test.cpp @@ -29,6 +29,7 @@ #include "events/types/filesystem_item_handle_closed.hpp" #include "events/types/filesystem_item_handle_opened.hpp" #include "events/types/filesystem_item_opened.hpp" +#include "events/types/item_timeout.hpp" #include "events/types/service_start_begin.hpp" #include "events/types/service_start_end.hpp" #include "events/types/service_stop_begin.hpp" @@ -132,7 +133,7 @@ TEST_F(file_manager_test, can_create_and_close_file) { mgr.start(); event_capture capture({ - "item_timeout", + item_timeout::name, filesystem_item_opened::name, filesystem_item_handle_opened::name, filesystem_item_handle_closed::name, @@ -241,7 +242,7 @@ TEST_F(file_manager_test, can_open_and_close_file) { mgr.start(); event_capture capture({ - "item_timeout", + item_timeout::name, filesystem_item_opened::name, filesystem_item_handle_opened::name, filesystem_item_handle_closed::name, @@ -647,7 +648,7 @@ TEST_F(file_manager_test, upload_occurs_after_write_if_fully_downloaded) { } event_capture capture({ - "item_timeout", + item_timeout::name, file_upload_queued::name, file_upload_completed::name, }); @@ -1463,7 +1464,7 @@ TEST_F(file_manager_test, file_is_closed_after_download_timeout) { auto source_path = utils::path::combine(cfg->get_cache_directory(), {utils::create_uuid_string()}); - event_consumer consumer("item_timeout", [](const i_event &evt) { + event_consumer consumer(item_timeout::name, [](const i_event &evt) { const auto &evt2 = dynamic_cast(evt); EXPECT_STREQ("/test_download_timeout.txt", evt2.get_api_path().get().c_str()); @@ -1489,7 +1490,7 @@ TEST_F(file_manager_test, file_is_closed_after_download_timeout) { return api_error::success; }); - event_capture capture({"item_timeout"}); + event_capture capture({item_timeout::name}); EXPECT_CALL(mp, read_file_bytes) .WillRepeatedly([](const std::string & /* api_path */, std::size_t size, @@ -1590,7 +1591,7 @@ TEST_F(file_manager_test, mgr.start(); event_capture capture({ - "item_timeout", + item_timeout::name, filesystem_item_opened::name, filesystem_item_handle_opened::name, filesystem_item_handle_closed::name,