Skip to content

Commit cbe57d6

Browse files
committed
fixup! update forwarding log messages
1 parent a85c4cc commit cbe57d6

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎src/ralph/api/forwarding.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ def get_active_xapi_forwardings() -> list[XapiForwardingConfigurationSettings]:
1616

1717
active_forwardings = []
1818
if not settings.XAPI_FORWARDINGS:
19-
logger.info("No xAPI forwarding is configured; forwarding is disabled.")
19+
logger.info("No xAPI forwarding configured; forwarding is disabled.")
2020
return active_forwardings
2121

2222
for forwarding in settings.XAPI_FORWARDINGS:
2323
if forwarding.is_active:
2424
active_forwardings.append(forwarding)
2525
continue
2626
msg = (
27-
"The RALPH_XAPI_FORWARDINGS configuration value: '%s' is not activated. "
27+
"The RALPH_XAPI_FORWARDINGS configuration value: '%s' is not active. "
2828
"It will be ignored."
2929
)
3030
logger.info(msg, forwarding)
@@ -49,4 +49,4 @@ async def forward_xapi_statements(statements: list[dict]):
4949
msg = "Forwarded %s statements to %s with success."
5050
logger.debug(msg, len(statements), forwarding.url)
5151
except (RequestError, HTTPStatusError) as error:
52-
logger.warning("Failed to forward xAPI statements. %s", error)
52+
logger.error("Failed to forward xAPI statements. %s", error)

‎tests/api/test_forwarding.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_api_forwarding_get_active_xapi_forwardings_with_empty_forwardings(
5959
configuration, should log that forwarding is inactive and return an empty list.
6060
"""
6161

62-
expected_log = "No xAPI forwarding is configured; forwarding is disabled."
62+
expected_log = "No xAPI forwarding configured; forwarding is disabled."
6363
# RALPH_XAPI_FORWARDINGS not set
6464
monkeypatch.delenv("RALPH_XAPI_FORWARDINGS", raising=False)
6565
monkeypatch.setattr("ralph.api.forwarding.settings", Settings())
@@ -108,7 +108,7 @@ def test_api_forwarding_get_active_xapi_forwardings_with_inactive_forwardings(
108108

109109
msg = (
110110
f"The RALPH_XAPI_FORWARDINGS configuration value: '{inactive_forwarding}' is "
111-
"not activated. It will be ignored."
111+
"not active. It will be ignored."
112112
)
113113
assert len(caplog.record_tuples) == 1
114114
assert caplog.record_tuples[0][2] == msg
@@ -163,6 +163,7 @@ async def post_success(*args, **kwargs): # pylint: disable=unused-argument
163163
monkeypatch.setenv("RALPH_XAPI_FORWARDINGS", f"[{forwarding.json()}]")
164164
monkeypatch.setattr("ralph.api.forwarding.settings", Settings())
165165

166+
caplog.clear()
166167
with caplog.at_level(logging.DEBUG):
167168
asyncio.get_event_loop().run_until_complete(forward_xapi_statements(statements))
168169

@@ -205,7 +206,7 @@ async def post_fail(*args, **kwargs): # pylint: disable=unused-argument
205206
monkeypatch.setenv("RALPH_XAPI_FORWARDINGS", f"[{forwarding.json()}]")
206207
monkeypatch.setattr("ralph.api.forwarding.settings", Settings())
207208

208-
with caplog.at_level(logging.DEBUG):
209+
with caplog.at_level(logging.ERROR):
209210
asyncio.get_event_loop().run_until_complete(forward_xapi_statements(statements))
210211

211212
assert ["Failed to forward xAPI statements. Something went wrong."] == [

0 commit comments

Comments
 (0)