9#include <spdlog/fmt/bundled/ranges.h>
10#include <spdlog/sinks/basic_file_sink.h>
11#include <spdlog/sinks/ostream_sink.h>
12#include <spdlog/sinks/stdout_color_sinks.h>
13#include <spdlog/spdlog.h>
24#define AutoPasLog(lvl, fmt, ...) SPDLOG_LOGGER_##lvl(spdlog::get("AutoPasLog"), fmt, ##__VA_ARGS__)
33 static inline auto loggerName() {
return "AutoPasLog"; };
44 static void create(std::string &filename) {
46 if (spdlog::get(loggerName())) {
49 spdlog::basic_logger_mt(loggerName(), filename);
57 static void create(std::ostream &oss = std::cout) {
59 if (spdlog::get(loggerName())) {
62 std::shared_ptr<spdlog::sinks::sink> ostreamSink;
63#ifdef AUTOPAS_COLORED_CONSOLE_LOGGING
64 if (oss.rdbuf() == std::cout.rdbuf()) {
65 ostreamSink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
66 }
else if (oss.rdbuf() == std::cerr.rdbuf()) {
67 ostreamSink = std::make_shared<spdlog::sinks::stderr_color_sink_mt>();
69 ostreamSink = std::make_shared<spdlog::sinks::ostream_sink_mt>(oss);
72 ostreamSink = std::make_shared<spdlog::sinks::ostream_sink_mt>(oss);
74 auto logger = std::make_shared<spdlog::logger>(loggerName(), ostreamSink);
75 spdlog::register_logger(logger);
90 static auto get() {
return spdlog::get(loggerName()); }
Logger class to provide interface to basic functions of the logger.
Definition: Logger.h:31
spdlog::level::level_enum LogLevel
Typalias for log levels.
Definition: Logger.h:39
static void create(std::ostream &oss=std::cout)
create a logger with an arbitrary ostream.
Definition: Logger.h:57
static void create(std::string &filename)
create a logger writing to the file system
Definition: Logger.h:44
static auto get()
Get a pointer to the actual logger object.
Definition: Logger.h:90
static void unregister()
removes the logger.
Definition: Logger.h:84
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32