nvim session file and zlib added
This commit is contained in:
34
src/main.cpp
34
src/main.cpp
@@ -1,9 +1,41 @@
|
||||
#include "clickhouse/client.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <sys/types.h>
|
||||
#include <toml++/toml.h>
|
||||
#include "processing_utils.hpp"
|
||||
|
||||
void process_directory(const std::string& dir_path,
|
||||
std::shared_ptr<clickhouse::Client> client,
|
||||
const std::string& target_user_id,
|
||||
bool all)
|
||||
{
|
||||
|
||||
if (all) {
|
||||
for (auto& entry : std::filesystem::directory_iterator(dir_path)) {
|
||||
if (!entry.is_regular_file()) continue;
|
||||
|
||||
std::string filename = entry.path().filename().string();
|
||||
|
||||
if (filename == "latest.log") continue;
|
||||
|
||||
if (filename.ends_with(".log") || filename.ends_with(".log.gz")) {
|
||||
processing_utils::process_to_eof(entry.path().string(), client, target_user_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Second pass: always follow latest.log
|
||||
std::filesystem::path latest_path = std::filesystem::path(dir_path) / "latest.log";
|
||||
if (std::filesystem::exists(latest_path) && std::filesystem::is_regular_file(latest_path)) {
|
||||
processing_utils::process_blocking(latest_path.string(), client, target_user_id);
|
||||
} else {
|
||||
spdlog::warn("latest.log not found in {}", dir_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
auto config = toml::parse_file("config.toml");
|
||||
@@ -22,5 +54,7 @@ int main (int argc, char *argv[]) {
|
||||
|
||||
std::shared_ptr<clickhouse::Client> shared_client = std::make_shared<clickhouse::Client>(clickhouse::ClientOptions().SetPassword(clickouse_password).SetDefaultDatabase(clickhouse_db).SetUser(clickhouse_username).SetHost(clickhouse_host).SetPort(clickhouse_port));
|
||||
spdlog::info("Server connection: {}", shared_client->GetServerInfo().display_name);
|
||||
spdlog::info("runnign on given path: {}", log_path);
|
||||
process_directory(log_path, shared_client, user_id, ingest_all_logs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user