示例#1
0
    def __init__(self, name, parent_logger=None):
        if parent_logger is None:
            self.name = "processor/%s" % name
        else:
            parent_name = parent_logger._context["name"]
            self.name = "%s/%s" % (parent_name, name)

        self.log = Logger.get_logger(self.name)
示例#2
0
    def __init__(self, name, parent_logger=None):
        if parent_logger is None:
            self.name = "processor/%s" % name
        else:
            parent_name = parent_logger._context["name"]
            self.name = "%s/%s" % (parent_name, name)

        self.log = Logger.get_logger(self.name)
def test_processor_with_child_logging():
    class TestClass(DataProcessor):
        def __init__(self, name, parent_logger):
            DataProcessor.__init__(self, name, parent_logger)
            self.passed = True

    root_logger = Logger.get_logger("processor/test-processor")
    t = TestClass("child", root_logger)

    t.log.info("Testing with child logger...")

    assert t.log._context["name"] == "processor/test-processor/child"
示例#4
0
def test_processor_with_child_logging():
    class TestClass(DataProcessor):
        def __init__(self, name, parent_logger):
            DataProcessor.__init__(self, name, parent_logger)
            self.passed = True

    root_logger = Logger.get_logger("processor/test-processor")
    t = TestClass("child", root_logger)

    t.log.info("Testing with child logger...")

    assert t.log._context["name"] == "processor/test-processor/child"
示例#5
0
    def __init__(self,
                 name="base-service",
                 directory_proxy=None,
                 parent_logger=None,
                 enable_service_recovery=False):
        """
        uuid - a uuid4 value for the service
        alias - a colloquial alias
        unique_name - a name which includes an easier to remember alias with the uuid

        :param name:
        :param directory_proxy:
        :param parent_logger:
        :return:
        """
        ErrorHandlerMixin.__init__(self)

        # time indexes
        self.time_starting_index = None  # time index when service was 'starting'
        self.time_started_index = None  # time index when service was started

        self.uuid = uuid4()  # unique uuid
        self.alias = name  # name, may collide
        self.unique_name = '%s/%s' % (
            self.alias, self.uuid
        )  # a unique name for this service, will always be unique
        scales.init(self, self.unique_name)

        if parent_logger is None:  # no parent, use fq name
            self.lineage = "%s" % self.unique_name
        else:
            parent_name = parent_logger._context["name"]
            self.lineage = "%s/%s" % (parent_name, self.unique_name)

        self.log = Logger.get_logger(self.lineage)
        self.greenlet = None
        self._service_state = None
        self.set_state(BaseStates.Idle)

        # directory service proxy
        self.directory_proxy = directory_proxy

        # service recovery option
        self.enable_service_recovery = enable_service_recovery

        self.log.debug("Initialized.")
示例#6
0
    def __init__(self,
                 name="base-service",
                 directory_proxy=None,
                 parent_logger=None,
                 enable_service_recovery=False):
        """
        uuid - a uuid4 value for the service
        alias - a colloquial alias
        unique_name - a name which includes an easier to remember alias with the uuid

        :param name:
        :param directory_proxy:
        :param parent_logger:
        :return:
        """
        ErrorHandlerMixin.__init__(self)

        # time indexes
        self.time_starting_index = None  # time index when service was 'starting'
        self.time_started_index = None  # time index when service was started

        self.uuid = uuid4()  # unique uuid
        self.alias = name  # name, may collide
        self.unique_name = '%s/%s' % (self.alias, self.uuid)  # a unique name for this service, will always be unique
        scales.init(self, self.unique_name)

        if parent_logger is None:  # no parent, use fq name
            self.lineage = "%s" % self.unique_name
        else:
            parent_name = parent_logger._context["name"]
            self.lineage = "%s/%s" % (parent_name, self.unique_name)

        self.log = Logger.get_logger(self.lineage)
        self.greenlet = None
        self._service_state = None
        self.set_state(BaseStates.Idle)

        # directory service proxy
        self.directory_proxy = directory_proxy

        # service recovery option
        self.enable_service_recovery = enable_service_recovery

        self.log.debug("Initialized.")