regulators: Add toString() method to Action class
Add a toString() method to the Action class and all child classes.
This method returns a string description of the action. The description
will be used in journal entries and error logs when an action fails
(such as due to an I2C error).
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: I083496d23bf9c3df5be1b082650a9def24be1b00
diff --git a/phosphor-regulators/src/actions/action.hpp b/phosphor-regulators/src/actions/action.hpp
index 4cbe76d..81b7b4d 100644
--- a/phosphor-regulators/src/actions/action.hpp
+++ b/phosphor-regulators/src/actions/action.hpp
@@ -17,6 +17,8 @@
#include "action_environment.hpp"
+#include <string>
+
namespace phosphor::power::regulators
{
@@ -54,6 +56,18 @@
* indicate if the action was successfully executed.
*/
virtual bool execute(ActionEnvironment& environment) = 0;
+
+ /**
+ * Returns a string description of this action.
+ *
+ * The description should include the action name, properties, and property
+ * values.
+ *
+ * The description is used in journal entries and error logs.
+ *
+ * @return description of action
+ */
+ virtual std::string toString() const = 0;
};
} // namespace phosphor::power::regulators