13#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
14#include <spdlog/spdlog.h>
16#if defined(SPDLOG_VER_MAJOR) && SPDLOG_VER_MAJOR >= 1
17#include <spdlog/sinks/basic_file_sink.h>
19#include <spdlog/sinks/file_sinks.h>
22#include <spdlog/fmt/ostr.h>
33 using Level = spdlog::level::level_enum;
34 using Log = std::shared_ptr<spdlog::logger>;
37 static Log create(
const std::string &name,
Level filelevel = Level::info,
38 Level clilevel = Level::off);
50 static Log get(
const std::string &name,
Level filelevel = Level::info,
51 Level clilevel = Level::off);
53 static void setLogLevel(std::shared_ptr<spdlog::logger> logger,
56 static void setLogPattern(std::shared_ptr<spdlog::logger> logger,
76#if FMT_VERSION >= 90000
78class fmt::formatter<
CPS::String> :
public fmt::ostream_formatter {};
80class fmt::formatter<
CPS::
Complex> :
public fmt::ostream_formatter {};
82class fmt::formatter<
CPS::
Vector> :
public fmt::ostream_formatter {};
84class fmt::formatter<
CPS::
VectorComp> :
public fmt::ostream_formatter {};
86class fmt::formatter<
CPS::
SparseMatrix> :
public fmt::ostream_formatter {};
95class fmt::formatter<
CPS::
Matrix> :
public fmt::ostream_formatter {};
97class fmt::formatter<
CPS::
MatrixComp> :
public fmt::ostream_formatter {};
99class fmt::formatter<
CPS::
MatrixInt> :
public fmt::ostream_formatter {};
101class fmt::formatter<
CPS::
MatrixRow> :
public fmt::ostream_formatter {};
103class fmt::formatter<
CPS::
LUFactorized> :
public fmt::ostream_formatter {};
107template <
typename VarType>
108class fmt::formatter<
CPS::
MatrixVar<VarType>> :
public fmt::ostream_formatter {
110template <
int rows,
int cols>
112 :
public fmt::ostream_formatter {};
113template <
int rows,
int cols>
115 :
public fmt::ostream_formatter {};
118class fmt::formatter<Eigen::Block<CPS::Matrix>>
119 :
public fmt::ostream_formatter {};
121class fmt::formatter<Eigen::Block<CPS::MatrixComp>>
122 :
public fmt::ostream_formatter {};
125template <
typename T>
struct formatter<CPS::Attribute<T>> {
126 template <
typename ParseContext>
constexpr auto parse(ParseContext &ctx) {
130 template <
typename FormatContext>
131 auto format(
const CPS::Attribute<T> &attr, FormatContext &ctx)
const {
132 auto &nc =
const_cast<CPS::Attribute<T> &
>(attr);
133 return fmt::format_to(ctx.out(),
"{}", nc.get());
137template <
typename T>
struct formatter<std::shared_ptr<CPS::Attribute<T>>> {
138 template <
typename ParseContext>
constexpr auto parse(ParseContext &ctx) {
142 template <
typename FormatContext>
143 auto format(
const std::shared_ptr<CPS::Attribute<T>> &p,
144 FormatContext &ctx)
const {
146 return fmt::format_to(ctx.out(),
"<null>");
147 auto &nc =
const_cast<CPS::Attribute<T> &
>(*p);
148 return fmt::format_to(ctx.out(),
"{}", nc.get());
spdlog::level::level_enum Level
std::shared_ptr< spdlog::logger > Log
static String matrixCompToString(const MatrixComp &mat)
static String phasorMatrixToString(const MatrixComp &mat)
static String sparseMatrixToString(const SparseMatrix &mat)
static void setLogDir(String path)
Set env variable CPS_LOG_DIR and overwrite.
static void setLogPattern(std::shared_ptr< spdlog::logger > logger, std::string pattern)
static Log get(const std::string &name, Level filelevel=Level::info, Level clilevel=Level::off)
static String complexToString(const Complex &num)
static String matrixToString(const Matrix &mat)
static void setLogLevel(std::shared_ptr< spdlog::logger > logger, Logger::Level level)
static String realToString(const Real &num)
static String getCSVLineFromData(Real time, Real data)
static String getCSVColumnNames(std::vector< String > names)
static String sparseMatrixCompToString(const SparseMatrixComp &mat)
static String phasorToString(const Complex &num)
struct dps_magma_data data
Eigen::SparseMatrix< Real, Eigen::ColMajor > SparseMatrix
Sparse matrix for real numbers.
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > Matrix
Dense matrix for real numbers.
Eigen::SparseMatrix< Complex, Eigen::ColMajor > SparseMatrixComp
Sparse matrix for complex numbers.
Eigen::Matrix< Int, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixInt
Dense matrix for integers.
Eigen::PartialPivLU< Matrix > LUFactorized
Eigen::SparseMatrix< Complex, Eigen::RowMajor > SparseMatrixCompRow
Sparse matrix for complex numbers (row major).
Eigen::Matrix< Real, rows, cols, Eigen::ColMajor > MatrixFixedSize
Dense matrix for real numbers with fixed dimension.
Eigen::Matrix< Complex, Eigen::Dynamic, 1 > VectorComp
Dense vector for complex numbers.
Eigen::Matrix< Real, Eigen::Dynamic, 1 > Vector
Dense vector for real numbers.
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > MatrixRow
std::complex< Real > Complex
Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > MatrixComp
Dense matrix for complex numbers.
Eigen::Matrix< Complex, rows, cols, Eigen::ColMajor > MatrixFixedSizeComp
Dense matrix for complex numbers with fixed dimension.
Eigen::SparseLU< SparseMatrix > LUFactorizedSparse
Eigen::SparseMatrix< Real, Eigen::RowMajor > SparseMatrixRow
Sparse matrix for real numbers (row major).
CPS::MatrixVar< T > MatrixVar
CPS::SparseMatrixRow SparseMatrix
CPS::SparseMatrixCompRow SparseMatrixComp
CPS::MatrixComp MatrixComp