Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions openeo/rest/models/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class LogEntry(dict):
between None and non-existing. None for example refers to no-data in
many cases while the absence of the property means that the user did
not provide any data for debugging.
- ``stacktrace``: Stacktrace for the error, string, optional, available since API 1.3.0
"""

_required = {"id", "level", "message"}
Expand Down Expand Up @@ -49,6 +50,11 @@ def message(self):
def level(self):
return self["level"]

@property
def stacktrace(self) -> Union[str, None]:
"""Stacktrace for the error, available since API 1.3.0. Returns None if not present."""
return self.get("stacktrace", None)

# TODO: add properties for "code", "time", "path", "links" and "data" with sensible defaults?


Expand Down
16 changes: 16 additions & 0 deletions tests/rest/models/test_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ def test_log_entry_legacy():
assert log.log_id == "log01"


def test_log_entry_stacktrace_missing():
log = LogEntry(id="log01", level="error", message="oops")
assert log.stacktrace is None


def test_log_entry_stacktrace_present():
log = LogEntry(
id="log01",
level="error",
message="oops",
stacktrace="line 1\nline 2\nline 3",
)
assert log.stacktrace == "line 1\nline 2\nline 3"
assert log["stacktrace"] == "line 1\nline 2\nline 3"


@pytest.mark.parametrize(
["log_level_in", "expected_log_level"],
[
Expand Down