diff options
Diffstat (limited to 'bindings/python/sample.py')
-rwxr-xr-x | bindings/python/sample.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/bindings/python/sample.py b/bindings/python/sample.py index f33ddeb..1208fc9 100755 --- a/bindings/python/sample.py +++ b/bindings/python/sample.py @@ -29,9 +29,28 @@ import PyPfw import sys +import logging + +class MyLogger(PyPfw.ILogger): + def __init__(self): + # Calling the base constructor is necessary: if you don't, MyLogger + # won't be recognised as a derived class of PyPfw.ILogger + super(MyLogger, self).__init__() + + def log(self, is_warning, log): + log_func = logging.warning if is_warning else logging.info + log_func(log) + + +logging.root.setLevel(logging.INFO) pfw = PyPfw.ParameterFramework(sys.argv[1]) +# warning: don't pass MyLogger() directly as argument to setLogger() or it will +# be garbage collected +mylogger = MyLogger() +pfw.setLogger(mylogger); + moodType = pfw.createSelectionCriterionType(False) for numerical, literal in enumerate(["mad", "sad", "glad"]): moodType.addValuePair(numerical, literal) |