Exemplo n.º 1
0
 def test_format_with_timestamp(self):
     log = TailFormatter('({timestamp}) - {message}',
                         color=False).format(self.message)
     timestamp_local_format = self.timestamp.to('local').format(
         utils.DEFAULT_DATE_FORMAT)
     self.assertEquals(
         '({}) - dummy message'.format(timestamp_local_format), log)
Exemplo n.º 2
0
 def test_format_with_blank_fields(self):
     log = TailFormatter('{blank_field}',
                         fields=['blank_field'],
                         color=False).format(self.message)
     self.assertEquals('', log)
Exemplo n.º 3
0
 def test_format_with_custom_fields(self):
     log = TailFormatter('{a} {b} {c}', fields=['a', 'b', 'c'],
                         color=False).format(self.message)
     self.assertEquals('1 2 3', log)
Exemplo n.º 4
0
 def test_format_with_log_level(self):
     log = TailFormatter('({level}) - {message}',
                         color=False).format(self.message)
     self.assertEquals('(DEBUG) - dummy message', log)
Exemplo n.º 5
0
 def test_format_colored_with_level_critical(self):
     self.message.level = syslog.LOG_CRIT
     log = TailFormatter('({source}) - {message}',
                         color=True).format(self.message)
     self.assertEquals(
         colored('(dummy.source) - dummy message', 'white', 'on_red'), log)
Exemplo n.º 6
0
 def test_format_colored_with_level_warning(self):
     self.message.level = syslog.LOG_WARNING
     log = TailFormatter('({source}) - {message}',
                         color=True).format(self.message)
     self.assertEquals(colored('(dummy.source) - dummy message', 'yellow'),
                       log)
Exemplo n.º 7
0
 def test_format_colored_with_level_info(self):
     self.message.level = syslog.LOG_INFO
     log = TailFormatter('({source}) - {message}',
                         color=True).format(self.message)
     self.assertEquals(colored('(dummy.source) - dummy message', 'green'),
                       log)
Exemplo n.º 8
0
 def test_format_colored_with_level_debug(self):
     self.message.level = syslog.LOG_DEBUG
     log = TailFormatter('({source}) - {message}',
                         color=True).format(self.message)
     self.assertEquals(colored('(dummy.source) - dummy message', 'cyan'),
                       log)
Exemplo n.º 9
0
 def test_format(self):
     log = TailFormatter('({source}) - {message}',
                         color=False).format(self.message)
     self.assertEquals('(dummy.source) - dummy message', log)