Exemplo n.º 1
def message_fnc(id_, message, data):
    Process a message from the actor.
    @param _id: Ids used by actors to identify themself and locate services to witch they belongs
    @param message: Mesagge received from actor
    @param data: Extra data
    ids = id_.split(",")[:5]  # Limit ids received to five...
    logger.debug("Called message for id_ {0}, message \"{1}\" and data \"{2}\"".format(ids, message, data))

    # Fix: Log used to send "INFO", "DEBUG", .. as level instead of numeric
    # Now, we use levels, so for "legacy" actors we can do logs correctly
    if message == 'log':
            msg, level = data.split('\t')
            logger.debug('Msg: {}, level: "{}"'.format(msg, level))
            level = "{}".format(log.logLevelFromStr(level))
            logger.debug('Level: "{}"'.format(level))
            data = '\t'.join([msg, level])
        except Exception:
            logger.exception("Exception at log")
            data = data.replace('\t', ' ') + '\t10000'  # Other

    res = ""
        services = UserService.objects.filter(unique_id__in=ids, state__in=[State.USABLE, State.PREPARING])
        if services.count() == 0:
            res = ""
            res = services[0].getInstance().osmanager().process(services[0], message, data, None)
    except Exception as e:
        logger.error("Exception at message (client): {0}".format(e))
        res = ""
    logger.debug("Returning {0}".format(res))
    return res
Exemplo n.º 2
    def doLog(self, wichObject, level, message, source, avoidDuplicates=True):
        Do the logging for the requested object.

        If the object provided do not accepts associated loggin, it simply ignores the request
        if type(level) is not int:
            level = log.logLevelFromStr(level)

        owner_type = transDict.get(type(wichObject), None)
        if owner_type is not None:
            self.__log(owner_type, wichObject.id, level, message, source, avoidDuplicates)
            logger.debug('Requested doLog for a type of object not covered: {0}'.format(wichObject))