message.h 670 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // format.hpp
  3. // logger
  4. //
  5. // Created by Sam Jaffe on 8/21/16.
  6. //
  7. #pragma once
  8. #include <string>
  9. #include <vector>
  10. #include "wrapper_object.h"
  11. namespace logging {
  12. class message {
  13. private:
  14. std::string format_code;
  15. std::vector<detail::object> objects;
  16. public:
  17. message() = default;
  18. message(char const * fmt) : format_code(fmt) {}
  19. template <typename... Args>
  20. message(std::string const & fmt, Args &&... args);
  21. std::string str() const;
  22. Json::Value json() const;
  23. };
  24. template <typename... Args>
  25. message::message(std::string const & fmt, Args &&... args)
  26. : format_code(fmt), objects({detail::object(args)...}) {}
  27. }