diff --git a/include/caosdb/logging.h b/include/caosdb/logging.h index e50c70f69bc0ed45e8f6a60f78cd11e4142b0568..94c78ed3d6c303149e755c4aa83e757a04500724 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 7aaedee77696ada264418c104b6c8c28c4bb7b24..ecc34d668971eaa22cd7ff727d8f54c84c2f3bdc 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;