def test_log_custom_output(self): test_string = 'custom output message' custom_output = StringIO() expected_output = self._factor_log_output(test_string, verbose=True, level='INFO') with freeze_time(LOG_DATETIME): logger = LstailLogger(CONFIG, output=custom_output, verbose=True) logger.info(test_string) # check for output in custom output output = custom_output.getvalue().strip() self.assertEqual(output, expected_output) # check there is no output on default sys.stdout output = sys.stdout.getvalue().strip() # pylint: disable=no-member self.assertEqual(output, '')
def test_log_info_nested_column(self): config = deepcopy(CONFIG) config.no_header = False config.kibana.default_columns = CONFIG_DEFAULT_COLUMNS_NESTED config.display.columns[ CONFIG_COLUMN_NESTED_NAME] = CONFIG_COLUMN_NESTED test_string = 'info nested test message' test_nested = dict(nested=dict(column=dict(test='nested'))) expected_output = '{} INFO nested {}'.format( LOG_TIMESTAMP, test_string) with freeze_time(LOG_DATETIME): logger = LstailLogger(config, output=sys.stdout, verbose=False) logger.info(test_string, extra=test_nested) # check output = sys.stdout.getvalue().strip() # pylint: disable=no-member self.assertEqual(output, expected_output)