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/if_action.hpp b/phosphor-regulators/src/actions/if_action.hpp
index 13b9860..10b2f5b 100644
--- a/phosphor-regulators/src/actions/if_action.hpp
+++ b/phosphor-regulators/src/actions/if_action.hpp
@@ -19,6 +19,7 @@
 #include "action_environment.hpp"
 
 #include <memory>
+#include <string>
 #include <utility>
 #include <vector>
 
@@ -126,6 +127,22 @@
         return elseActions;
     }
 
+    /**
+     * Returns a string description of this action.
+     *
+     * @return description of action
+     */
+    virtual std::string toString() const override
+    {
+        std::string description{"if: { condition: { ... }, then: [ ... ]"};
+        if (elseActions.size() > 0)
+        {
+            description += ", else: [ ... ]";
+        }
+        description += " }";
+        return description;
+    }
+
   private:
     /**
      * Action that tests whether the condition is true.