Commit 50bcafea authored by Devaev Maxim's avatar Devaev Maxim

Fixed bug with logging, added tracer for dbus API

parent e4a3f944
[service]
bus_type = session
log_level = 2
[hello]
enabled = yes
......@@ -15,7 +15,7 @@ ConfigDictObject = {
"name" : (const.DEFAULT_SERVICE_NAME, str),
"path" : (const.DEFAULT_SERVICE_PATH, str),
"bus_type" : (const.DEFAULT_SERVICE_BUS_TYPE, ( lambda arg : validators.validRange(arg, const.ALL_SERVICE_BUS_TYPES_LIST) )),
"log_level" : (const.DEFAULT_LOG_LEVEL, ( lambda arg : int(validators.validRange(arg, const.ALL_LOG_LEVELS_LIST)) ))
"log_level" : (const.DEFAULT_LOG_LEVEL, ( lambda arg : validators.validRange(int(arg), const.ALL_LOG_LEVELS_LIST) ))
}
}
......@@ -34,7 +34,7 @@ def setValue(section, option, value, validator = None) :
try :
value = validator(value)
except Exception, err1 :
raise validators.ValidatorError("Incorrect config option \"%s :: %s = %s\"" % (section, option, value, str(err1)))
raise validators.ValidatorError("Incorrect config option \"%s :: %s = %s\": %s" % (section, option, value, str(err1)))
ConfigDictObject[section][option] = (value, validator)
......
......@@ -14,6 +14,7 @@ def message(log_level, message) :
"%s [ Details ]:" % (const.MY_NAME), # const.LOG_LEVEL_VERBOSE == 1
"%s [ Debug ]:" % (const.MY_NAME) # # const.LOG_LEVEL_DEBUG == 2
]
if log_level <= config.value("service", "log_level") :
print >> sys.stderr, text_log_levels_list[log_level], message
......@@ -5,9 +5,11 @@ import dbus.service
import dbus.glib
import abc
import const
import config
import shared
import dbus_tools
import logger
#####
......@@ -57,9 +59,21 @@ class ActionObject(CustomObject) :
######
def tracer(function) :
def wrapper(self, *args_list, **kwargs_dict) :
return_value = function(self, *args_list, **kwargs_dict)
logger.message(const.LOG_LEVEL_DEBUG, "Called \"%s::%s\" with args (%s, %s) --> %s" % (
self.__class__.__name__, function.__name__, str(args_list), str(kwargs_dict), str(return_value) ))
return return_value
wrapper.__dict__ = function.__dict__
wrapper.__name__ = function.__name__
return wrapper
def customMethod(interface_name) :
def decorator(function) :
return dbus.service.method(interface_name)(function)
return tracer(dbus.service.method(interface_name)(function))
return decorator
def functionMethod(interface_name) :
......
......@@ -20,6 +20,5 @@ def validBool(arg) :
def validRange(arg, valid_args_list) :
if not arg in valid_args_list :
raise ValidatorError("Argument \"%s\" not in list %s" % (arg, valid_args_list))
return ( arg in valid_args_list )
return arg
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment