11#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
12#include <spdlog/spdlog.h>
14#if defined(SPDLOG_VER_MAJOR) && SPDLOG_VER_MAJOR >= 1
15#include <spdlog/sinks/basic_file_sink.h>
17#include <spdlog/sinks/file_sinks.h>
20#include <spdlog/fmt/ostr.h>
22#include <dpsim-models/Definitions.h>
23#include <dpsim-models/MathUtils.h>
30 using Level = spdlog::level::level_enum;
31 using Log = std::shared_ptr<spdlog::logger>;
34 static Log create(
const std::string &name, Level filelevel = Level::info,
35 Level clilevel = Level::off);
41 static String prefix();
42 static String logDir();
47 static Log get(
const std::string &name, Level filelevel = Level::info,
48 Level clilevel = Level::off);
50 static void setLogLevel(std::shared_ptr<spdlog::logger> logger,
53 static void setLogPattern(std::shared_ptr<spdlog::logger> logger,
57 static String matrixToString(
const Matrix &mat);
58 static String matrixCompToString(
const MatrixComp &mat);
59 static String sparseMatrixToString(
const SparseMatrix &mat);
60 static String sparseMatrixCompToString(
const SparseMatrixComp &mat);
61 static String phasorMatrixToString(
const MatrixComp &mat);
62 static String phasorToString(
const Complex &num);
63 static String complexToString(
const Complex &num);
64 static String realToString(
const Real &num);
66 static String getCSVColumnNames(std::vector<String> names);
67 static String getCSVLineFromData(Real time, Real data);
68 static String getCSVLineFromData(Real time,
const Matrix &data);
69 static String getCSVLineFromData(Real time,
const MatrixComp &data);
73#if FMT_VERSION >= 90000
75class fmt::formatter<CPS::Complex> :
public fmt::ostream_formatter {};
77class fmt::formatter<CPS::Vector> :
public fmt::ostream_formatter {};
79class fmt::formatter<CPS::VectorComp> :
public fmt::ostream_formatter {};
81class fmt::formatter<CPS::SparseMatrix> :
public fmt::ostream_formatter {};
83class fmt::formatter<CPS::SparseMatrixRow> :
public fmt::ostream_formatter {};
85class fmt::formatter<CPS::SparseMatrixComp> :
public fmt::ostream_formatter {};
87class fmt::formatter<CPS::SparseMatrixCompRow> :
public fmt::ostream_formatter {
90class fmt::formatter<CPS::Matrix> :
public fmt::ostream_formatter {};
92class fmt::formatter<CPS::MatrixComp> :
public fmt::ostream_formatter {};
94class fmt::formatter<CPS::MatrixInt> :
public fmt::ostream_formatter {};
96class fmt::formatter<CPS::MatrixRow> :
public fmt::ostream_formatter {};
98class fmt::formatter<CPS::LUFactorized> :
public fmt::ostream_formatter {};
100class fmt::formatter<CPS::LUFactorizedSparse> :
public fmt::ostream_formatter {
102template <
typename VarType>
103class fmt::formatter<CPS::MatrixVar<VarType>> :
public fmt::ostream_formatter {
105template <
int rows,
int cols>
106class fmt::formatter<CPS::MatrixFixedSize<rows, cols>>
107 :
public fmt::ostream_formatter {};
108template <
int rows,
int cols>
109class fmt::formatter<CPS::MatrixFixedSizeComp<rows, cols>>
110 :
public fmt::ostream_formatter {};
113class fmt::formatter<Eigen::Block<CPS::Matrix>>
114 :
public fmt::ostream_formatter {};
116class fmt::formatter<Eigen::Block<CPS::MatrixComp>>
117 :
public fmt::ostream_formatter {};
static void setLogDir(String path)
Set env variable CPS_LOG_DIR and overwrite.