def __init__(self, serial=u"", action=u"", success=u"False", tokentype=u"", user=u"", realm=u"", administrator=u"", action_detail=u"", info=u"", linotp_server=u"", client=u"", log_level=u"INFO", clearance_level=0, config_param=None): """ build an audit db entry *parmeters require to be compliant to the table defintion, which implies that type unicode is recomended where appropriate :param serial: token serial number :type serial: unicode :param action: the scope of the audit entry, eg. admin/show :type action: unicode :param success: the result of the action :type success: unicode :param tokentype: which token type was involved :type tokentype: unicode :param user: user login :type user: unicode :param realm: the involved realm :type realm: unicode :param administrator: the admin involved :type administrator: unicode :param action_detail: the additional action details :type action_detail: unicode :param info: additional info for failures :type info: unicode :param linotp_server: the server name :type linotp_server: unicode :param client: info about the requesting client :type client: unicode :param loglevel: the loglevel of the action :type loglevel: unicode :param clearance_level: *??* :type clearance_level: integer """ log.debug("[__init__] creating AuditTable object, action = %s" % action) if config_param: self.config = config_param else: self.config = config self.trunc_as_err = self.config.get('linotpAudit.error_on_truncation', 'False') == 'True' self.serial = unicode(serial or '') self.action = unicode(action or '') self.success = unicode(success or '0') self.tokentype = unicode(tokentype or '') self.user = unicode(user or '') self.realm = unicode(realm or '') self.administrator = unicode(administrator or '') # # we have to truncate the 'action_detail' and the 'info' data # in utf-8 compliant way # self.action_detail = utf8_slice(unicode(action_detail or ''), 512).next() self.info = utf8_slice(unicode(info or ''), 512).next() self.linotp_server = unicode(linotp_server or '') self.client = unicode(client or '') self.log_level = unicode(log_level or '') self.clearance_level = clearance_level self.timestamp = now() self.siganture = ' '