Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update log format.
  • Loading branch information
kinyoklion committed Jun 26, 2025
commit f4f8ae44852019997fba61383496df4e877f351d
2 changes: 1 addition & 1 deletion ldclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def __register_plugins(self, environment_metadata: EnvironmentMetadata):
try:
plugin.register(self, environment_metadata)
except Exception as e:
log.error(f"Error registering plugin {plugin.metadata.name}: {e}")
log.error("Error registering plugin %s: %s", plugin.metadata.name, e)

def _set_event_processor(self, config):
if config.offline or not config.send_events:
Expand Down
20 changes: 14 additions & 6 deletions ldclient/testing/test_ldclient_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,13 @@ def test_plugin_error_handling_get_hooks(self):

# Verify that the error was logged with the correct message
mock_log_error.assert_called_once()
error_call_args = mock_log_error.call_args[0]
self.assertIn("Error getting hooks from plugin Error Plugin", error_call_args[0])
self.assertIn("Get hooks error in Error Plugin", str(error_call_args))
# Check the format string and arguments separately
format_string = mock_log_error.call_args[0][0]
format_args = mock_log_error.call_args[0][1:]
self.assertEqual(format_string, "Error getting hooks from plugin %s: %s")
self.assertEqual(len(format_args), 2)
self.assertEqual(format_args[0], "Error Plugin")
self.assertIn("Get hooks error in Error Plugin", str(format_args[1]))

def test_plugin_error_handling_register(self):
"""Test that errors during plugin registration are handled gracefully."""
Expand Down Expand Up @@ -237,9 +241,13 @@ def test_plugin_error_handling_register(self):

# Verify that the error was logged with the correct message
mock_log_error.assert_called_once()
error_call_args = mock_log_error.call_args[0]
self.assertIn("Error registering plugin Error Plugin", error_call_args[0])
self.assertIn("Registration error in Error Plugin", str(error_call_args))
# Check the format string and arguments separately
format_string = mock_log_error.call_args[0][0]
format_args = mock_log_error.call_args[0][1:]
self.assertEqual(format_string, "Error registering plugin %s: %s")
self.assertEqual(len(format_args), 2)
self.assertEqual(format_args[0], "Error Plugin")
self.assertIn("Registration error in Error Plugin", str(format_args[1]))

def test_plugin_with_existing_hooks(self):
"""Test that plugin hooks work alongside existing hooks and config hooks are called before plugin hooks."""
Expand Down