From ec2ed2fb324d92573418afcc17365c83373023ec Mon Sep 17 00:00:00 2001 From: Brad Bishop Date: Wed, 31 May 2017 21:10:43 -0400 Subject: Fix bool and string templates/rendering Fix a number of bugs related to rendering and instantiation of string and bool templates. Change-Id: Ic75842b4016f4d96bf5850f9c4ad778d82e075ed Signed-off-by: Brad Bishop --- src/journal.hpp | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'src/journal.hpp') diff --git a/src/journal.hpp b/src/journal.hpp index 4e47670..cc74451 100644 --- a/src/journal.hpp +++ b/src/journal.hpp @@ -46,6 +46,28 @@ class JournalBase : public IndexedCallback const char* message; }; +/** @struct Display + * @brief Convert strings to const char*. + */ +namespace detail +{ +template struct Display +{ + static auto op(T&& value) + { + return std::forward(value); + } +}; + +template <> struct Display +{ + static auto op(const std::string& value) + { + return value.c_str(); + } +}; +} // namespace detail + /** @class Journal * @brief C++ type specific logic for the journal callback. * @@ -77,11 +99,11 @@ class Journal : public JournalBase phosphor::logging::log( message, phosphor::logging::entry( - pathMeta + GetFormat::format, - path), + (pathMeta + GetFormat::format).c_str(), + path.c_str()), phosphor::logging::entry( - propertyMeta + GetFormat::format, - any_ns::any_cast(value))); + (propertyMeta + GetFormat::format).c_str(), + detail::Display::op(any_ns::any_cast(value)))); } }; -- cgit v1.2.1