summaryrefslogtreecommitdiffstats
path: root/src/journal.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/journal.hpp')
-rw-r--r--src/journal.hpp30
1 files changed, 26 insertions, 4 deletions
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 <typename T> struct Display
+{
+ static auto op(T&& value)
+ {
+ return std::forward<T>(value);
+ }
+};
+
+template <> struct Display<std::string>
+{
+ 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<Severity>(
message,
phosphor::logging::entry(
- pathMeta + GetFormat<decltype(pathMeta)>::format,
- path),
+ (pathMeta + GetFormat<decltype(pathMeta)>::format).c_str(),
+ path.c_str()),
phosphor::logging::entry(
- propertyMeta + GetFormat<T>::format,
- any_ns::any_cast<T>(value)));
+ (propertyMeta + GetFormat<T>::format).c_str(),
+ detail::Display<T>::op(any_ns::any_cast<T>(value))));
}
};
OpenPOWER on IntegriCloud