Example #1
0
 def test_format_basics(self):
     thing1 = factory.make_name("thing")
     thing2 = factory.make_name("thing")
     log_system = factory.make_name("system")
     log_format = ">{thing1}< >{thing2}<"
     log_time = pick_log_time()
     self.assertThat(
         _formatModernEvent({
             "log_time": log_time,
             "log_format": log_format,
             "log_system": log_system,
             "log_level": self.log_level,
             "thing1": thing1,
             "thing2": thing2,
         }),
         Equals(
             "%s %s: [%s] >%s< >%s<\n" %
             (logger.formatTime(log_time, DEFAULT_LOG_FORMAT_DATE),
              log_system, self.log_level.name, thing1, thing2), ),
     )
Example #2
0
 def test_format_failure(self):
     try:
         1 / 0
     except ZeroDivisionError:
         failure = Failure()
     log_system = factory.make_name("system")
     log_time = pick_log_time()
     self.assertThat(
         _formatModernEvent({
             "log_time": log_time,
             "log_system": log_system,
             "log_level": self.log_level,
             "log_failure": failure,
         }),
         Equals(
             "%s %s: [%s] \n\t%s\n" %
             (logger.formatTime(log_time, DEFAULT_LOG_FORMAT_DATE),
              log_system, self.log_level.name,
              failure.getTraceback().replace("\n", "\n\t")), ),
     )