Skip to content

Commit

Permalink
Merge pull request #138 from project-tsurugi/wip/i_817
Browse files Browse the repository at this point in the history
replace constants with those provided by Altimeter
  • Loading branch information
t-horikawa authored Jun 20, 2024
2 parents ed25b47 + 7481ab2 commit 053e118
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/tateyama/altimeter/altimeter_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@
* limitations under the License.
*/

#include <iostream>
#include <filesystem>

#include <glog/logging.h>

#include <tateyama/api/configuration.h>
#include <tateyama/altimeter/events.h>

#include <altimeter/configuration.h>
#include <altimeter/log_item.h>
#include <altimeter/logger.h>

#include <altimeter/audit/constants.h>
#include <altimeter/event/constants.h>
#include <altimeter/event/event_logger.h>

#include "altimeter_helper.h"

namespace tateyama::altimeter {
Expand All @@ -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<bool>("output").value());
configuration.directory(section->get<std::filesystem::path>("directory").value().string());
configuration.level(section->get<int>("level").value());
Expand All @@ -49,6 +56,19 @@ void altimeter_helper::setup(::altimeter::configuration& configuration, tateyama
configuration.flush_interval(section->get<std::size_t>("flush_interval").value());
configuration.flush_file_size(section->get<std::size_t>("flush_file_size").value());
configuration.max_file_size(section->get<std::size_t>("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<std::size_t>("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) {
Expand Down
1 change: 1 addition & 0 deletions src/tateyama/configuration/bootstrap_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 053e118

Please sign in to comment.