From 7481ab290ca213d160e87531f1ea84c194c5acce Mon Sep 17 00:00:00 2001 From: t-horikawa Date: Thu, 20 Jun 2024 17:09:37 +0900 Subject: [PATCH] replace constants with those provided by Altimeter --- src/tateyama/altimeter/altimeter_helper.cpp | 24 +++++++++++++++++-- .../configuration/bootstrap_configuration.cpp | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/tateyama/altimeter/altimeter_helper.cpp b/src/tateyama/altimeter/altimeter_helper.cpp index e0f16f8..538dfbd 100644 --- a/src/tateyama/altimeter/altimeter_helper.cpp +++ b/src/tateyama/altimeter/altimeter_helper.cpp @@ -14,14 +14,21 @@ * limitations under the License. */ +#include #include #include #include -#include + +#include +#include #include +#include +#include +#include + #include "altimeter_helper.h" namespace tateyama::altimeter { @@ -39,7 +46,7 @@ altimeter_helper::~altimeter_helper() { // The following method is created with reference to altimeter/logger/examples/altimeter/main.cpp // void altimeter_helper::setup(::altimeter::configuration& configuration, tateyama::api::configuration::section* section, log_type type) { - configuration.category((type == log_type::event_log) ? log_category::event : log_category::audit); + configuration.category((type == log_type::event_log) ? ::altimeter::event::category : ::altimeter::audit::category); configuration.output(section->get("output").value()); configuration.directory(section->get("directory").value().string()); configuration.level(section->get("level").value()); @@ -49,6 +56,19 @@ void altimeter_helper::setup(::altimeter::configuration& configuration, tateyama configuration.flush_interval(section->get("flush_interval").value()); configuration.flush_file_size(section->get("flush_file_size").value()); configuration.max_file_size(section->get("max_file_size").value()); + if (type == log_type::event_log) { + configuration.error_handler([](std::string_view error_message) { + std::cout << "Failed to flush or rotate event log files: " + << error_message << "\n"; + }); + // FIXME implement set_slow_query_time() in altimeter::event::event_logger + // ::altimeter::event::event_logger::set_slow_query_time(section->get("slow_query_time").value()); + } else { + configuration.error_handler([](std::string_view error_message) { + std::cout << "Failed to flush or rotate audit log files: " + << error_message << "\n"; + }); + } std::string_view log_type_name = (type == log_type::event_log) ? "event log" : "audit log"; configuration.error_handler([log_type_name](std::string_view error_message) { diff --git a/src/tateyama/configuration/bootstrap_configuration.cpp b/src/tateyama/configuration/bootstrap_configuration.cpp index 994b6eb..4884f3d 100644 --- a/src/tateyama/configuration/bootstrap_configuration.cpp +++ b/src/tateyama/configuration/bootstrap_configuration.cpp @@ -83,6 +83,7 @@ static constexpr std::string_view default_configuration { // NOLINT "flush_interval=10000\n" "flush_file_size=1048576\n" "max_file_size=1073741824\n" + "slow_query_time=1000000000\n" "[audit_log]\n" "output=true\n"