Merge pull request #624 from yarda/functions-debug
functions: added 'log' which helps with debugging
This commit is contained in:
commit
b37d8efd5c
2 changed files with 20 additions and 0 deletions
19
tuned/profiles/functions/function_log.py
Normal file
19
tuned/profiles/functions/function_log.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import tuned.logs
|
||||
from . import base
|
||||
|
||||
log = tuned.logs.get()
|
||||
|
||||
class execute(base.Function):
|
||||
"""
|
||||
Expands to concatenation of arguments and logs the result, useful for debugging.
|
||||
"""
|
||||
def __init__(self):
|
||||
# unlimited number of arguments, min 1 argument (the value to log)
|
||||
super(execute, self).__init__("log", 0, 1)
|
||||
|
||||
def execute(self, args):
|
||||
if not super(execute, self).execute(args):
|
||||
return None
|
||||
s = "".join(args)
|
||||
log.info(s)
|
||||
return s
|
||||
|
|
@ -56,6 +56,7 @@ class Functions():
|
|||
log.error("function '%s' not implemented" % sl[1])
|
||||
return
|
||||
s = f.execute(sl[2:])
|
||||
log.debug("${f:%s} expands to: '%s'" % (":".join(sl[1:]), s))
|
||||
if s is None:
|
||||
return
|
||||
self._sub(_from, self._cnt, s)
|
||||
|
|
|
|||
Loading…
Reference in a new issue