From 47a4713c935d0f56340244a8bcbcfd0fa6ba555a Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Fri, 8 Jul 2022 17:23:49 +0200
Subject: [PATCH] FIX: add more operator<< variants to logging

---
 include/caosdb/logging.h |  3 +++
 src/caosdb/logging.cpp   | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/include/caosdb/logging.h b/include/caosdb/logging.h
index e50c70f..94c78ed 100644
--- a/include/caosdb/logging.h
+++ b/include/caosdb/logging.h
@@ -27,6 +27,7 @@
 #include <cstdint>            // for uint64_t
 #include <iosfwd>             // for streamsize
 #include <memory>             // for shared_ptr
+#include <ostream>            // for ostream
 #include <string>             // for string
 #include <vector>             // for vector
 
@@ -37,6 +38,8 @@ const std::string logger_name = "caosdb::logging";
 class LoggerOutputStream {
 public:
   LoggerOutputStream(std::string channel, int level);
+  auto operator<<(std::ostream &(*f)(std::ostream &)) -> LoggerOutputStream &;
+  auto operator<<(bool msg) -> LoggerOutputStream &;
   auto operator<<(int msg) -> LoggerOutputStream &;
   auto operator<<(uint64_t msg) -> LoggerOutputStream &;
   auto operator<<(int64_t msg) -> LoggerOutputStream &;
diff --git a/src/caosdb/logging.cpp b/src/caosdb/logging.cpp
index 7aaedee..ecc34d6 100644
--- a/src/caosdb/logging.cpp
+++ b/src/caosdb/logging.cpp
@@ -63,6 +63,18 @@ private:
 LoggerOutputStream::LoggerOutputStream(std::string channel, int level)
   : channel(std::move(channel)), level(level) {}
 
+auto LoggerOutputStream::operator<<(std::ostream &(*f)(std::ostream &)) -> LoggerOutputStream & {
+  BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), this->channel, this->level) << f;
+
+  return *this;
+}
+
+auto LoggerOutputStream::operator<<(bool msg) -> LoggerOutputStream & {
+  BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), this->channel, this->level) << msg;
+
+  return *this;
+}
+
 auto LoggerOutputStream::operator<<(std::streambuf *msg) -> LoggerOutputStream & {
   BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel, this->level) << msg;
 
-- 
GitLab