You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 line
796 B

  1. #pragma once
  2. namespace utl {
  3. namespace logging {
  4. struct log_message
  5. {
  6. private:
  7. std::ostringstream _msg;
  8. public:
  9. inline std::string str() const
  10. { return _msg.str(); }
  11. template <typename T>
  12. inline log_message& operator <<(const T& value)
  13. {
  14. _msg << value;
  15. return *this;
  16. }
  17. inline log_message& operator <<(std::ostream& (*callback)(std::ostream&))
  18. {
  19. callback(_msg);
  20. return *this;
  21. }
  22. log_message() :
  23. _msg()
  24. { }
  25. log_message(const std::string& msg) :
  26. _msg(msg)
  27. { }
  28. private:
  29. log_message(log_message&&) = delete;
  30. log_message(const log_message&) = delete;
  31. };
  32. }
  33. }