Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,23 @@ auto main(int argc, char** argv) -> std::int32_t {
return EXIT_FAILURE;
}

const auto& cache_path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
const auto& log_filepath = fmt::format("{}/cachyospi.log", cache_path.toStdString());
if (fs::exists(log_filepath)) {
std::ifstream currentfile{log_filepath};
const std::string file_data{std::istreambuf_iterator<char>(currentfile), std::istreambuf_iterator<char>()};
std::ofstream oldlogfile{fmt::format("{}.old", log_filepath)};
oldlogfile << "-----------------------------------------------------------\nCACHYOSPI SESSION\n"
"-----------------------------------------------------------\n";
oldlogfile << file_data;
fs::remove(log_filepath);
}
auto logger = spdlog::create_async<spdlog::sinks::basic_file_sink_mt>("cachyos_logger", log_filepath);
spdlog::set_default_logger(logger);
spdlog::set_pattern("[%r][%^---%L---%$] %v");
spdlog::set_level(spdlog::level::debug);
spdlog::flush_every(std::chrono::seconds(5));

// Check if we have valid databases
{
if (!alpm::is_valid_alpm_dbs()) {
Expand Down Expand Up @@ -194,23 +211,6 @@ auto main(int argc, char** argv) -> std::int32_t {
return EXIT_FAILURE;
}

const auto& cache_path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
const auto& log_filepath = fmt::format("{}/cachyospi.log", cache_path.toStdString());
if (fs::exists(log_filepath)) {
std::ifstream currentfile{log_filepath};
const std::string file_data{std::istreambuf_iterator<char>(currentfile), std::istreambuf_iterator<char>()};
std::ofstream oldlogfile{fmt::format("{}.old", log_filepath)};
oldlogfile << "-----------------------------------------------------------\nCACHYOSPI SESSION\n"
"-----------------------------------------------------------\n";
oldlogfile << file_data;
fs::remove(log_filepath);
}
auto logger = spdlog::create_async<spdlog::sinks::basic_file_sink_mt>("cachyos_logger", log_filepath);
spdlog::set_default_logger(logger);
spdlog::set_pattern("[%r][%^---%L---%$] %v");
spdlog::set_level(spdlog::level::debug);
spdlog::flush_every(std::chrono::seconds(5));

MainWindow w;
w.show();
const auto& status_code = QApplication::exec();
Expand Down