PolyFEM
Loading...
Searching...
No Matches
Logger.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <spdlog/fmt/bundled/ranges.h>
5#include <spdlog/fmt/ostr.h>
6#include <spdlog/spdlog.h>
8
9namespace polyfem
10{
16 spdlog::logger &logger();
22 spdlog::logger &adjoint_logger();
23
30 void set_logger(std::shared_ptr<spdlog::logger> logger);
31
38 void set_adjoint_logger(std::shared_ptr<spdlog::logger> logger);
39
40 [[noreturn]] void log_and_throw_error(const std::string &msg);
41 [[noreturn]] void log_and_throw_adjoint_error(const std::string &msg);
42
43 template <typename... Args>
44 [[noreturn]] void log_and_throw_error(const std::string &msg, const Args &...args)
45 {
46 log_and_throw_error(fmt::format(msg, args...));
47 }
48
49 template <typename... Args>
50 [[noreturn]] void log_and_throw_adjoint_error(const std::string &msg, const Args &...args)
51 {
52 log_and_throw_error(fmt::format(msg, args...));
53 }
54} // namespace polyfem
spdlog::logger & logger()
Retrieves the current logger.
Definition Logger.cpp:42
spdlog::logger & adjoint_logger()
Retrieves the current logger for adjoint.
Definition Logger.cpp:28
void set_adjoint_logger(std::shared_ptr< spdlog::logger > p_logger)
Setup a logger object to be used by adjoint Polyfem.
Definition Logger.cpp:66
void log_and_throw_adjoint_error(const std::string &msg)
Definition Logger.cpp:77
void set_logger(std::shared_ptr< spdlog::logger > p_logger)
Setup a logger object to be used by Polyfem.
Definition Logger.cpp:60
void log_and_throw_error(const std::string &msg)
Definition Logger.cpp:71