dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
logging.cpp
1
7#include "logging.h"
8
9#ifndef NLOG
10
11#include <spdlog/common.h>
12#include <spdlog/sinks/stdout_color_sinks.h>
13#include <spdlog/spdlog.h>
14
15namespace dlinear {
16
17std::shared_ptr<spdlog::logger> get_logger(LoggerType logger_type) {
18 // Checks if there exists a logger with the name. If it exists, return it.
19 const char *logger_name = logger_type == LoggerType::OUT ? "dlinear_out" : "dlinear_err";
20 std::shared_ptr<spdlog::logger> logger{spdlog::get(logger_name)};
21 if (logger) return logger;
22
23 // Create and return a new logger.
24 logger = logger_type == LoggerType::OUT ? spdlog::stdout_color_mt(logger_name) : spdlog::stderr_color_mt(logger_name);
25
26 // Turn it off by default so that external programs using dReal as a library do not see internal loggings.
27 logger->set_level(spdlog::level::off);
28
29 // Set format.
30 logger->set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%^%l%$] [thread %t] %v");
31
32 return logger;
33}
34
35} // namespace dlinear
36
37#else
38
39#endif // NLOG
Global namespace for the dlinear library.