Skip to content

Commit

Permalink
fix: custom license usage source support
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoral-splunk committed Aug 5, 2024
1 parent cad8ca7 commit 7a0ea37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion solnlib/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@ def events_ingested(

result = {
"action": "events_ingested",
"modular_input_name": license_usage_source if license_usage_source else modular_input_name,
"modular_input_name": license_usage_source
if license_usage_source
else modular_input_name,
"sourcetype_ingested": sourcetype,
"n_events": n_events,
"event_input": input_name,
Expand Down
18 changes: 11 additions & 7 deletions tests/unit/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,12 @@ def test_events_ingested_invalid_input():
def test_events_ingested_custom_license_usage():
with mock.patch("logging.Logger") as mock_logger:
log.events_ingested(
mock_logger, "input_type://input_name", "sourcetype", 5, "default",
license_usage_source="custom:license:source"
mock_logger,
"input_type://input_name",
"sourcetype",
5,
"default",
license_usage_source="custom:license:source",
)

mock_logger.log.assert_called_once_with(
Expand All @@ -265,7 +269,7 @@ def test_events_ingested_custom_license_usage():
"default",
host="abcd",
account="test_acc",
license_usage_source="custom:license:source:123"
license_usage_source="custom:license:source:123",
)

mock_logger.log.assert_called_once_with(
Expand Down Expand Up @@ -350,13 +354,13 @@ def test_log_format(monkeypatch, tmp_path):
log_content = transform_log(log_file.read_text())

assert (
log_content
== dedent(
"""
log_content
== dedent(
"""
2024-03-23 10:15:20,555 log_level=WARNING pid=1234 tid=MainThread file=test_file.py:test_func:123 | log 2
2024-03-23 10:15:20,555 log_level=ERROR pid=1234 tid=MainThread file=test_file.py:test_func:123 | log 3
""",
).lstrip()
).lstrip()
)


Expand Down

0 comments on commit 7a0ea37

Please sign in to comment.