Loading [MathJax]/extensions/tex2jax.js
PolyFEM
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
10
11namespace polyfem
12{
18 spdlog::logger &logger();
24 spdlog::logger &adjoint_logger();
25
32 void set_logger(std::shared_ptr<spdlog::logger> logger);
33
40 void set_adjoint_logger(std::shared_ptr<spdlog::logger> logger);
41
42 [[noreturn]] void log_and_throw_error(const std::string &msg);
43 [[noreturn]] void log_and_throw_adjoint_error(const std::string &msg);
44
45 template <typename... Args>
46 [[noreturn]] void log_and_throw_error(const std::string &msg, const Args &...args)
47 {
48 log_and_throw_error(fmt::format(msg, args...));
49 }
50
51 template <typename... Args>
52 [[noreturn]] void log_and_throw_adjoint_error(const std::string &msg, const Args &...args)
53 {
54 log_and_throw_error(fmt::format(msg, args...));
55 }
56} // namespace polyfem
57
58template <>
59struct fmt::formatter<polyfem::StiffnessMatrix> : fmt::formatter<fmt::string_view>
60{
61 format_context::iterator format(const polyfem::StiffnessMatrix &mat, fmt::format_context &ctx) const;
62};
63
64template <>
65struct fmt::formatter<Eigen::MatrixXd> : fmt::formatter<fmt::string_view>
66{
67 format_context::iterator format(const Eigen::MatrixXd &mat, fmt::format_context &ctx) const;
68};
spdlog::logger & logger()
Retrieves the current logger.
Definition Logger.cpp:44
spdlog::logger & adjoint_logger()
Retrieves the current logger for adjoint.
Definition Logger.cpp:30
void set_adjoint_logger(std::shared_ptr< spdlog::logger > p_logger)
Setup a logger object to be used by adjoint Polyfem.
Definition Logger.cpp:68
void log_and_throw_adjoint_error(const std::string &msg)
Definition Logger.cpp:79
void set_logger(std::shared_ptr< spdlog::logger > p_logger)
Setup a logger object to be used by Polyfem.
Definition Logger.cpp:62
void log_and_throw_error(const std::string &msg)
Definition Logger.cpp:73
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix
Definition Types.hpp:22