Esempio n. 1
0
 def test__ignores_protocol_starting_on_events(self):
     event = make_event(
         "%s starting on %d" %
         (factory.make_name("protocol"), factory.pick_port()))
     with TwistedLoggerFixture() as logger:
         observe_twisted_internet_unix(event)
     self.assertThat(logger.events, HasLength(0))
Esempio n. 2
0
 def test__ignores_port_closed_events(self):
     event = make_event(
         "(%s Port %r Closed)" %
         (factory.make_name("port-name"), factory.make_name("port")))
     with TwistedLoggerFixture() as logger:
         observe_twisted_internet_unix(event)
     self.assertThat(logger.events, HasLength(0))
Esempio n. 3
0
 def test_filters_by_noise(self):
     self.setLogLevel(self.log_level)
     common = dict(log_namespace="log_legacy", log_system="-")
     noisy = [
         make_event("Log opened.", **common),
         make_event("Main loop terminated.", **common),
     ]
     for event in noisy:
         self.log(event)
     okay = [make_event(log_level=self.log_level, **common)]
     for event in okay:
         self.log(event)
     # Only the `okay` logs will get through.
     expected = [("-", self.log_level.name, event["log_text"])
                 for event in okay]
     self.assertSequenceEqual(expected, self.get_logs())
Esempio n. 4
0
 def test_basics(self):
     self.setLogLevel(self.log_level)
     event = make_event(log_level=self.log_level)
     event["log_system"] = factory.make_name("system")
     self.log(event)
     self.assertSequenceEqual(
         [(event["log_system"], self.log_level.name, event["log_text"])],
         self.get_logs(),
     )
Esempio n. 5
0
 def test_filters_by_level(self):
     self.setLogLevel(self.log_level)
     events = {
         log_level: make_event(log_level=log_level)
         for log_level in logger.LogLevel.iterconstants()
     }
     for event in events.values():
         self.log(event)
     # Only the log at the current level will get through.
     self.assertSequenceEqual(
         [("-", self.log_level.name, events[self.log_level]["log_text"])],
         self.get_logs(),
     )
Esempio n. 6
0
 def test__propagates_other_events(self):
     event = make_event(factory.make_name("something"))
     with TwistedLoggerFixture() as logger:
         observe_twisted_internet_unix(event)
     self.assertThat(logger.events, Contains(event))
Esempio n. 7
0
 def test__propagates_other_events(self):
     event = make_event(log_level=self.log_level)
     with TwistedLoggerFixture() as logger:
         observe_tftp(event)
     self.assertThat(logger.events, Contains(event))
     self.assertThat(event["log_level"], Is(self.log_level))
Esempio n. 8
0
 def test__downgrades_informational_messages(self):
     event = make_event(log_level=LogLevel.info)
     with TwistedLoggerFixture() as logger:
         observe_tftp(event)
     self.assertThat(logger.events, Contains(event))
     self.assertThat(event["log_level"], Is(LogLevel.debug))