From 3ae2285ea457f74084ff3a2a054679472109a082 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 7 Jul 2021 10:36:38 +0200 Subject: [PATCH] plugin: add support for spdlog custom formatter --- common/include/villas/plugin.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/include/villas/plugin.hpp b/common/include/villas/plugin.hpp index f62dce2f3..1ff5b2970 100644 --- a/common/include/villas/plugin.hpp +++ b/common/include/villas/plugin.hpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -139,6 +140,13 @@ public: virtual std::string getDescription() const = 0; + /** Custom formatter for spdlog */ + template + friend OStream &operator<<(OStream &os, const class Plugin &p) + { + return os << p.getName(); + } + protected: std::string path; @@ -160,7 +168,7 @@ Registry::dumpList() for (Plugin *p : *plugins) { T *t = dynamic_cast(p); if (t) - getLogger()->info(" - {}: {}", p->getName(), p->getDescription()); + getLogger()->info(" - {}: {}", *p, p->getDescription()); } }