14#include <dune/common/parallel/mpihelper.hh>
16#include <spdlog/details/registry.h>
17#include <spdlog/fmt/chrono.h>
18#include <spdlog/fmt/ostr.h>
19#include <spdlog/fmt/ranges.h>
20#include <spdlog/sinks/basic_file_sink.h>
21#include <spdlog/sinks/stdout_color_sinks.h>
22#include <spdlog/spdlog.h>
50 using namespace std::chrono;
51 std::string currentTime = fmt::format(
"_{}", std::chrono::system_clock::now());
53 std::ranges::transform(currentTime, currentTime.begin(), [](
char ch) {
54 return (ch ==
' ' or ch ==
':') ?
'_' : ch;
56 auto logFilename = (filename.empty() ? executableName : filename) + currentTime +
".log";
57 auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(logFilename,
true);
58 file_sink->set_pattern(
"%v");
59 file_sink->set_level(spdlog::level::trace);
60 auto logger = spdlog::default_logger();
61 logger->sinks().push_back(file_sink);
67 std::string executableName;
81 void inline init(
int argc,
char** argv,
bool enableFileLogger =
true) {
82 Dune::MPIHelper::instance(argc, argv);
84 instance.executableName = argv[0];
85 auto logger = spdlog::default_logger();
86 logger->set_pattern(
"%v");
87 if (enableFileLogger) instance.enableFileLogger();
89 auto currentTime = std::chrono::system_clock::now();
90 const std::chrono::year_month_day currentYearMonthDay{floor<std::chrono::days>(currentTime)};
92 spdlog::info(
"Start of execution: {}", currentTime);
94 spdlog::info(R
"xxx( _/_/_/ _/ _/ _/_/ _/_/_/ _/ _/ _/_/_/)xxx");
95 spdlog::info(R"xxx( _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ )xxx");
96 spdlog::info(R"xxx( _/ _/_/ _/_/_/_/ _/_/_/ _/ _/ _/_/ )xxx");
97 spdlog::info(R"xxx( _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ )xxx");
98 spdlog::info(R"xxx(_/_/_/ _/ _/ _/ _/ _/ _/ _/_/ _/_/_/ )xxx");
100 spdlog::info("© 2021-{} The Ikarus Developers, see LICENSE.md ",
static_cast<int>(currentYearMonthDay.year()));
101 spdlog::info(
"You are using Ikarus v{}. Please don't forget to cite us:", IKARUS_VERSION);
103 "Müller, A., & Vinod Kumar Mitruka, T. K. M. (2023). Ikarus v0.3 (Version V1). Version V1. "
104 "doi:<https://doi.org/10.18419/darus-3303>");
Definition: simpleassemblers.hh:21
void init(int argc, char **argv, bool enableFileLogger=true)
Initializes the Ikarus framework.
Definition: init.hh:81
Singleton class representing an instance of the Ikarus framework.
Definition: init.hh:32
friend void init(int argc, char **argv, bool enableFileLogger)
Initializes the Ikarus framework.
Definition: init.hh:81
IkarusInstance(IkarusInstance const &)=delete
static IkarusInstance & getInstance()
Gets the singleton instance of the Ikarus framework.
Definition: init.hh:39
void operator=(IkarusInstance const &)=delete
void enableFileLogger(std::string &&filename="")
Enables a file logger.
Definition: init.hh:49