message.h 681 B

1234567891011121314151617181920212223242526272829303132333435
  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. public:
  14. message() = default;
  15. message(char const * fmt) : format_code(fmt) {}
  16. template <typename... Args>
  17. message(std::string const & fmt, Args && ...args);
  18. std::string str() const;
  19. Json::Value json() const;
  20. private:
  21. std::string format_code;
  22. std::vector<detail::object> objects;
  23. };
  24. template <typename... Args>
  25. message::message(std::string const & fmt, Args && ...args)
  26. : format_code(fmt), objects({detail::object(args)...}) {
  27. }
  28. }