Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log stacktraces only in debug mode #2366

Merged
merged 2 commits into from
Mar 7, 2024
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
4 changes: 0 additions & 4 deletions python/tests/test_preequilibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,6 @@ def test_simulation_errors(preeq_fixture):
)
assert rdata._swigptr.messages[1].severity == amici.LogSeverity_error
assert rdata._swigptr.messages[1].identifier == "OTHER"
assert rdata._swigptr.messages[2].severity == amici.LogSeverity_debug
assert rdata._swigptr.messages[2].identifier == "BACKTRACE"

# too long simulations
solver.setMaxSteps(int(1e4))
Expand All @@ -632,8 +630,6 @@ def test_simulation_errors(preeq_fixture):
)
assert rdata._swigptr.messages[2].severity == amici.LogSeverity_error
assert rdata._swigptr.messages[2].identifier == "OTHER"
assert rdata._swigptr.messages[3].severity == amici.LogSeverity_debug
assert rdata._swigptr.messages[3].identifier == "BACKTRACE"


def test_get_model_for_preeq(preeq_fixture):
Expand Down
3 changes: 2 additions & 1 deletion src/amici.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,12 @@ std::unique_ptr<ReturnData> runAmiciSimulation(
LogSeverity::error, "OTHER", "AMICI simulation failed: %s",
ex.what()
);
#ifndef NDEBUG
logger.log(
LogSeverity::debug, "BACKTRACE",
"The previous error occurred at:\n%s", ex.getBacktrace()
);

#endif
} catch (std::exception const& ex) {
rdata->status = AMICI_ERROR;
if (rethrow)
Expand Down
Loading