コード例 #1
0
def make_observer_chain(ultimate_observer, indent):
    """
    Return our feature observers wrapped our the ultimate_observer
    """
    add_to_fanout(
        ObserverWrapper(JSONObserverWrapper(ultimate_observer,
                                            sort_keys=True,
                                            indent=indent or None),
                        hostname=socket.gethostname()))

    return throttling_wrapper(
        SpecificationObserverWrapper(
            PEP3101FormattingWrapper(
                SystemFilterWrapper(
                    ErrorFormattingWrapper(cf_id_wrapper(get_fanout()))))))
コード例 #2
0
ファイル: test_log.py プロジェクト: rackerlabs/otter
    def test_add_cf_id_to_cloud_feeds_events(self):
        """
        CF event dictionaries have an ID added to them, non-CF events do not.
        """
        obs = []
        id_observer = cf_id_wrapper(obs.append)
        id_observer({'cloud_feed': True, 'this': 'is a cf event'})
        id_observer({'this': 'is not a cf event'})

        def hex_repeat(num):
            return "[a-fA-F0-9]{{{num}}}".format(num=num)

        uuid_regex = "-".join([hex_repeat(i) for i in (8, 4, 4, 4, 12)])
        self.assertEqual(
            obs,
            [{'cloud_feed': True, 'this': 'is a cf event',
              'cloud_feed_id': matches(MatchesRegex(uuid_regex))},
             {'this': 'is not a cf event'}])
コード例 #3
0
ファイル: setup.py プロジェクト: rackerlabs/otter
def make_observer_chain(ultimate_observer, indent):
    """
    Return our feature observers wrapped our the ultimate_observer
    """
    add_to_fanout(
        ObserverWrapper(
            JSONObserverWrapper(
                ultimate_observer,
                sort_keys=True,
                indent=indent or None),
            hostname=socket.gethostname()))

    return throttling_wrapper(
        SpecificationObserverWrapper(
            PEP3101FormattingWrapper(
                SystemFilterWrapper(
                    ErrorFormattingWrapper(
                        cf_id_wrapper(
                            get_fanout()))))))
コード例 #4
0
ファイル: test_log.py プロジェクト: stephamon/otter
    def test_add_cf_id_to_cloud_feeds_events(self):
        """
        CF event dictionaries have an ID added to them, non-CF events do not.
        """
        obs = []
        id_observer = cf_id_wrapper(obs.append)
        id_observer({'cloud_feed': True, 'this': 'is a cf event'})
        id_observer({'this': 'is not a cf event'})

        def hex_repeat(num):
            return "[a-fA-F0-9]{{{num}}}".format(num=num)

        uuid_regex = "-".join([hex_repeat(i) for i in (8, 4, 4, 4, 12)])
        self.assertEqual(obs,
                         [{
                             'cloud_feed': True,
                             'this': 'is a cf event',
                             'cloud_feed_id': matches(MatchesRegex(uuid_regex))
                         }, {
                             'this': 'is not a cf event'
                         }])