sbmlteam / libsbml

LibSBML is a native library for reading, writing and manipulating files and data streams containing the Systems Biology Markup Language (SBML). It offers language bindings for C, C++, C#, Java, JavaScript, MATLAB, Perl, PHP, Python, R and Ruby.
https://sbml.org/software/libsbml
Other
38 stars 28 forks source link

Give access to document error log in C API #329

Closed avandecreme closed 10 months ago

avandecreme commented 1 year ago

It would be nice to have access to the error log from the C API.

My use case is that I might get some errors from some checks/conversion. I will then fix them and re-run those checks/conversion. If I do that, calling SBMLDocument_getNumErrors(doc) will count the errors from both checks/conversion runs whereas I only want the ones from the second run.

For most checks, I can rely on the number of errors returned by the check and compute the offset of the first relevant error. However, the conversion returns a boolean instead of a number of errors so I cannot do that. I still found a workaround in that case, the level and version converter actually clears the log (except in case of early return) so I can set the offset to 0.

Still, I think that being able to clear the log from the C API would be nice. While there is an API to clear the log, there is no way to retrieve the log object from a document.

So my request would be to add something like:

LIBSBML_EXTERN
const SBMLErrorLog_t *
SBMLDocument_getErrorLog(SBMLDocument_t *d)
{
  return (d != NULL) ? d->getErrorLog() : NULL;
}

I am not sure about SBMLErrorLog_t since it doesn't exist at the moment. Returning XMLErrorLog_t instead would be fine for my use case.

What do you think?