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>
51 using namespace std::chrono;
52 std::string currentTime = fmt::format(
"_{}", std::chrono::system_clock::now());
54 std::ranges::transform(currentTime, currentTime.begin(), [](
char ch) {
55 return (ch ==
' ' or ch ==
':') ?
'_' : ch;
57 auto logFilename = (filename.empty() ? executableName_ : filename) + currentTime +
".log";
58 auto fileSink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(logFilename,
true);
59 fileSink->set_pattern(
"%v");
60 fileSink->set_level(spdlog::level::trace);
61 auto logger = spdlog::default_logger();
62 logger->sinks().push_back(fileSink);
68 std::string executableName_;
82void inline init(
int argc,
char** argv,
bool enableFileLogger =
true) {
83 Dune::MPIHelper::instance(argc, argv);
85 instance.executableName_ = argv[0];
86 auto logger = spdlog::default_logger();
87 logger->set_pattern(
"%v");
89 instance.enableFileLogger();
91 auto currentTime = std::chrono::system_clock::now();
92 const std::chrono::year_month_day currentYearMonthDay{floor<std::chrono::days>(currentTime)};
94 spdlog::info(
"Start of execution: {}", currentTime);
96 spdlog::info(R
"xxx( _/_/_/ _/ _/ _/_/ _/_/_/ _/ _/ _/_/_/)xxx");
97 spdlog::info(R"xxx( _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ )xxx");
98 spdlog::info(R"xxx( _/ _/_/ _/_/_/_/ _/_/_/ _/ _/ _/_/ )xxx");
99 spdlog::info(R"xxx( _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ )xxx");
100 spdlog::info(R"xxx(_/_/_/ _/ _/ _/ _/ _/ _/ _/_/ _/_/_/ )xxx");
102 spdlog::info("© 2021-{} The Ikarus Developers, see LICENSE.md ",
static_cast<int>(currentYearMonthDay.year()));
103 spdlog::info(
"You are using Ikarus v{}. Please don't forget to cite us:", IKARUS_VERSION);
105 "Müller, A., Vinod Kumar Mitruka, T. K. M., Jakob, H. (2024). Ikarus v0.4 (Version V1). "
106 "doi:<https://doi.org/10.18419/darus-3889>");
Definition: assemblermanipulatorbuildingblocks.hh:22
void init(int argc, char **argv, bool enableFileLogger=true)
Initializes the Ikarus framework.
Definition: init.hh:82
Singleton class representing an instance of the Ikarus framework.
Definition: init.hh:33
friend void init(int argc, char **argv, bool enableFileLogger)
Initializes the Ikarus framework.
Definition: init.hh:82
static IkarusInstance & getInstance()
Gets the singleton instance of the Ikarus framework.
Definition: init.hh:40
void operator=(const IkarusInstance &)=delete
void enableFileLogger(std::string &&filename="")
Enables a file logger.
Definition: init.hh:50
IkarusInstance(const IkarusInstance &)=delete