Martin Sivák has uploaded a new change for review. Change subject: Add (debug ...) command to enable logging from inside the policy ......................................................................
Add (debug ...) command to enable logging from inside the policy Change-Id: I23dae405908a4d801dc9ac28a9fe2caff698f603 Signed-off-by: Martin Sivak <[email protected]> --- M mom/Policy/Parser.py M tests/ParserTests.py 2 files changed, 16 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/mom refs/changes/25/21725/1 diff --git a/mom/Policy/Parser.py b/mom/Policy/Parser.py index 709f238..6237a24 100644 --- a/mom/Policy/Parser.py +++ b/mom/Policy/Parser.py @@ -13,6 +13,7 @@ # You should have received a copy of the GNU General Public # License along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +import logging import re from spark import GenericScanner, GenericParser @@ -371,13 +372,18 @@ 'symbol value' return self.stack.set(name, value) - # setq is an alias to set here, note that in lisp set evaluates it's frist argument as well + # setq is an alias to set here, note that in lisp set evaluates it's first argument as well c_setq = c_set def c_defvar(self, name, value): 'symbol value' return self.stack.set(name, value, True) + def c_debug(self, *values): + 'value ...' + logging.getLogger("mom.Evaluator").debug("debug: %s", values) + return values[-1] + def c_let(self, syms, *code): 'code code ...' if type(syms) != list: diff --git a/tests/ParserTests.py b/tests/ParserTests.py index 5d41ab2..012c015 100644 --- a/tests/ParserTests.py +++ b/tests/ParserTests.py @@ -323,8 +323,16 @@ balloonEnabled (setq balloonEnabled 2) balloonEnabled + (set balloonEnabled 3) + balloonEnabled """ - self.verify(pol, [1, 1, 2, 2]) + self.verify(pol, [1, 1, 2, 2, 3, 3]) + + def test_debug(self): + pol = """ + (debug "test" 1 nil "lala") + """ + self.verify(pol, ["lala"]) if __name__ == '__main__': unittest.main() -- To view, visit http://gerrit.ovirt.org/21725 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I23dae405908a4d801dc9ac28a9fe2caff698f603 Gerrit-PatchSet: 1 Gerrit-Project: mom Gerrit-Branch: master Gerrit-Owner: Martin Sivák <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
