def test_format(self):
    formatter = GelfLogFormatter()
    expected_keys = ['version', 'host', 'short_message', 'full_message', 'timestamp', 'timestamp_f', 'level']
    mock_message = 'test message 1'
    record = MockRecord()
    record.msg = mock_message
    message = formatter.format(record=record)
    parsed = json.loads(message)
    for key in expected_keys:
        self.assertIn(key, parsed)
    self.assertEqual(parsed['short_message'], mock_message)
    self.assertEqual(parsed['full_message'], mock_message)
    mock_message = 'test message 2'
    record = MockRecord()
    record.msg = mock_message
    record._user_id = 1
    record._value = 'bar'
    record.ignored = 'foo'
    record.created = 1234.5678
    message = formatter.format(record=record)
    parsed = json.loads(message)
    for key in expected_keys:
        self.assertIn(key, parsed)
    self.assertEqual(parsed['short_message'], mock_message)
    self.assertEqual(parsed['full_message'], mock_message)
    self.assertEqual(parsed['_user_id'], 1)
    self.assertEqual(parsed['_value'], 'bar')
    self.assertEqual(parsed['timestamp'], 1234)
    self.assertEqual(parsed['timestamp_f'], 1234.5678)
    self.assertNotIn('ignored', parsed)
    mock_exception = Exception('mock exception bar')
    try:
        raise mock_exception
    except Exception:
        mock_exc_info = sys.exc_info()
    mock_message = 'test message 3'
    record = MockRecord()
    record.msg = mock_message
    record.exc_info = mock_exc_info
    message = formatter.format(record=record)
    parsed = json.loads(message)
    for key in expected_keys:
        self.assertIn(key, parsed)
    self.assertEqual(parsed['short_message'], mock_message)
    self.assertIn(mock_message, parsed['full_message'])
    self.assertIn('Traceback', parsed['full_message'])
    self.assertIn('_exception', parsed)
    self.assertIn('_traceback', parsed)
def test_format(self):
    formatter = GelfLogFormatter()
    expected_keys = ['version', 'host', 'short_message', 'full_message', 'timestamp', 'timestamp_f', 'level']
    mock_message = 'test message 1'
    record = MockRecord()
    record.msg = mock_message
    message = formatter.format(record=record)
    parsed = json.loads(message)
    for key in expected_keys:
        self.assertIn(key, parsed)
    self.assertEqual(parsed['short_message'], mock_message)
    self.assertEqual(parsed['full_message'], mock_message)
    mock_message = 'test message 2'
    record = MockRecord()
    record.msg = mock_message
    record._user_id = 1
    record._value = 'bar'
    record.ignored = 'foo'
    record.created = 1234.5678
    message = formatter.format(record=record)
    parsed = json.loads(message)
    for key in expected_keys:
        self.assertIn(key, parsed)
    self.assertEqual(parsed['short_message'], mock_message)
    self.assertEqual(parsed['full_message'], mock_message)
    self.assertEqual(parsed['_user_id'], 1)
    self.assertEqual(parsed['_value'], 'bar')
    self.assertEqual(parsed['timestamp'], 1234)
    self.assertEqual(parsed['timestamp_f'], 1234.5678)
    self.assertNotIn('ignored', parsed)
    mock_exception = Exception('mock exception bar')
    try:
        raise mock_exception
    except Exception:
        mock_exc_info = sys.exc_info()
    mock_message = 'test message 3'
    record = MockRecord()
    record.msg = mock_message
    record.exc_info = mock_exc_info
    message = formatter.format(record=record)
    parsed = json.loads(message)
    for key in expected_keys:
        self.assertIn(key, parsed)
    self.assertEqual(parsed['short_message'], mock_message)
    self.assertIn(mock_message, parsed['full_message'])
    self.assertIn('Traceback', parsed['full_message'])
    self.assertIn('_exception', parsed)
    self.assertIn('_traceback', parsed)