libSBML Python API  5.18.0
libsbml.SBMLErrorLog Class Reference
Inheritance diagram for libsbml.SBMLErrorLog:
[legend]

Detailed Description

Log of diagnostics reported during processing.

This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. This class is not prescribed by the SBML specifications, although it is used to implement features defined in SBML.

The error log is a list. Each SBMLDocument maintains its own SBMLErrorLog. When a libSBML operation on SBML content results in an error, or when there is something worth noting about the SBML content, the issue is reported as an SBMLError object stored in the SBMLErrorLog list.

SBMLErrorLog is derived from XMLErrorLog, an object class that serves exactly the same purpose but for the XML parsing layer. XMLErrorLog provides crucial methods such as getNumErrors() for determining how many SBMLError or XMLError objects are in the log. SBMLErrorLog inherits these methods.

The general approach to working with SBMLErrorLog in user programs involves first obtaining a pointer to a log from a libSBML object such as SBMLDocument. Callers should then use getNumErrors() to inquire how many objects there are in the list. (The answer may be 0.) If there is at least one SBMLError object in the SBMLErrorLog instance, callers can then iterate over the list using SBMLErrorLog.getError(), using methods provided by the SBMLError class to find out the error code and associated information such as the error severity, the message, and the line number in the input.

If you wish to simply print the error strings for a human to read, an easier and more direct way might be to use SBMLDocument.printErrors().

See also
SBMLError
XMLErrorLog
XMLError

Public Member Functions

def add (self, error)
 
def changeErrorSeverity (self, args)
 Changes the severity override for errors in the log that have a given severity. More...
 
def clearLog (self)
 Deletes all errors from this log. More...
 
def contains (self, errorId)
 Returns True if SBMLErrorLog contains an errorId. More...
 
def getError (self, n)
 Returns the nth SBMLError object in this log. More...
 
def getErrorWithSeverity (self, n, severity)
 Returns the nth SBMLError object with given severity in this log. More...
 
def getNumErrors (self)
 Returns the number of errors that have been logged. More...
 
def getNumFailsWithSeverity (self, args)
 Returns the number of errors that have been logged with the given severity code. More...
 
def getSeverityOverride (self)
 Returns the current override. More...
 
def isSeverityOverridden (self)
 Returns a boolean indicating whether or not the severity has been overridden. More...
 
def printErrors (self, args)
 This method has multiple variants; they differ in the arguments they accept. More...
 
def remove (self, errorId)
 Removes an error having errorId from the SBMLError list. More...
 
def removeAll (self, errorId)
 Removes all errors having errorId from the SBMLError list. More...
 
def setSeverityOverride (self, severity)
 Set the severity override. More...
 
def toString (self)
 Writes all errors contained in this log to a string and returns it. More...
 
def unsetSeverityOverride (self)
 Usets an existing override. More...
 

Member Function Documentation

def libsbml.SBMLErrorLog.add (   self,
  error 
)
add(SBMLError error)
def libsbml.XMLErrorLog.changeErrorSeverity (   self,
  args 
)
inherited

Changes the severity override for errors in the log that have a given severity.

changeErrorSeverity(long originalSeverity, long targetSeverity, string package)
changeErrorSeverity(long originalSeverity, long targetSeverity)

This method searches through the list of errors in the log, comparing each one's severity to the value of originalSeverity. For each error encountered with that severity logged by the named package, the severity of the error is reset to targetSeverity.

The severity override mechanism in XMLErrorLog is intended to help applications handle error conditions in ways that may be more convenient for those applications. It is possible to use the mechanism to override the severity code of errors logged by libSBML, and even to disable error logging completely. An override stays in effect until the override is changed again by the calling application.
Parameters
originalSeveritythe severity code to match.
targetSeveritythe severity code to use as the new severity.
packagea string, the name of an SBML Level 3 package extension to use to narrow the search for errors. A value of 'all' signifies to match against errors logged from any package; a value of a package nickname such as 'comp' signifies to limit consideration to errors from just that package. If no value is provided, 'all' is the default.
See also
isSeverityOverridden()
getSeverityOverride()
setSeverityOverride()
unsetSeverityOverride()
Note
Owing to the way that language interfaces are created in libSBML, this documentation may show methods that define default values for parameters with text that has the form parameter = value. This is not to be intepreted as a Python keyword argument; the use of a parameter name followed by an equals sign followed by a value is only meant to indicate a default value if the argument is not provided at all. It is not a keyword in the Python sense.
def libsbml.XMLErrorLog.clearLog (   self)
inherited

Deletes all errors from this log.

clearLog()
 
def libsbml.SBMLErrorLog.contains (   self,
  errorId 
)

Returns True if SBMLErrorLog contains an errorId.

Parameters
errorIdthe error identifier of the error to be found.
contains(long   errorId)   bool
 
def libsbml.SBMLErrorLog.getError (   self,
  n 
)

Returns the nth SBMLError object in this log.

getError(long  n)   SBMLError

Index n is counted from 0. Callers should first inquire about the number of items in the log by using the getNumErrors() method. Attempts to use an error index number that exceeds the actual number of errors in the log will result in a None being returned.

Parameters
nthe index number of the error to retrieve (with 0 being the first error).
Returns
the nth SBMLError in this log, or None if n is greater than or equal to getNumErrors().
See also
getNumErrors()
def libsbml.SBMLErrorLog.getErrorWithSeverity (   self,
  n,
  severity 
)

Returns the nth SBMLError object with given severity in this log.

getErrorWithSeverity(long  n, long  severity)   SBMLError

Index n is counted from 0. Callers should first inquire about the number of items in the log by using the getNumFailsWithSeverity() method. Attempts to use an error index number that exceeds the actual number of errors in the log will result in a None being returned.

Parameters
nthe index number of the error to retrieve (with 0 being the first error).
severitythe severity of the error to retrieve.
Returns
the nth SBMLError in this log, or None if n is greater than or equal to getNumFailsWithSeverity().
See also
getNumFailsWithSeverity()
def libsbml.XMLErrorLog.getNumErrors (   self)
inherited

Returns the number of errors that have been logged.

getNumErrors()   long

To retrieve individual errors from the log, callers may use XMLErrorLog.getError() .

Returns
the number of errors that have been logged.
def libsbml.SBMLErrorLog.getNumFailsWithSeverity (   self,
  args 
)

Returns the number of errors that have been logged with the given severity code.

getNumFailsWithSeverity(long  severity)   long
LibSBML associates severity levels with every SBMLError object to provide an indication of how serious the problem is. Severities range from informational diagnostics to fatal (irrecoverable) errors. Given an SBMLError object instance, a caller can interrogate it for its severity level using methods such as SBMLError.getSeverity(), SBMLError.isFatal(), and so on. The present method encapsulates iteration and interrogation of all objects in an SBMLErrorLog, making it easy to check for the presence of error objects with specific severity levels.
Parameters
severitya value from the set of LIBSBML_SEV_ constants defined by the interface class libsbml.
Returns
a count of the number of errors with the given severity code.
See also
getNumErrors()
def libsbml.XMLErrorLog.getSeverityOverride (   self)
inherited

Returns the current override.

getSeverityOverride()   long
The severity override mechanism in XMLErrorLog is intended to help applications handle error conditions in ways that may be more convenient for those applications. It is possible to use the mechanism to override the severity code of errors logged by libSBML, and even to disable error logging completely. An override stays in effect until the override is changed again by the calling application.
Returns
a severity override code. The possible values are drawn from the set of integer constants whose names begin with the prefix LIBSBML_OVERRIDE_:
See also
isSeverityOverridden()
setSeverityOverride()
unsetSeverityOverride()
changeErrorSeverity()
def libsbml.XMLErrorLog.isSeverityOverridden (   self)
inherited

Returns a boolean indicating whether or not the severity has been overridden.

isSeverityOverridden()   bool
The severity override mechanism in XMLErrorLog is intended to help applications handle error conditions in ways that may be more convenient for those applications. It is possible to use the mechanism to override the severity code of errors logged by libSBML, and even to disable error logging completely. An override stays in effect until the override is changed again by the calling application.
Returns
True if an error severity override has been set, False otherwise.
See also
getSeverityOverride()
setSeverityOverride()
unsetSeverityOverride()
changeErrorSeverity()
def libsbml.XMLErrorLog.printErrors (   self,
  args 
)
inherited

This method has multiple variants; they differ in the arguments they accept.

printErrors(ostream stream)
printErrors()
printErrors(ostream stream, long  severity)

Each variant is described separately below.


Method variant with the following signature:
printErrors(std::ostream stream, long severity)

Prints the errors or warnings with given severity stored in this error log.

This method prints the text to the stream given by the optional parameter stream. If no stream is given, the method prints the output to the standard error stream.

The format of the output is:

   N error(s):
     line NNN: (id) message

If no errors with that severity was found, then no output will be produced.

Parameters
streamthe ostream or ostringstream object indicating where the output should be printed.
severitythe severity of the errors sought.

Method variant with the following signature:
printErrors(std::ostream stream = std::cerr)

Prints all the errors or warnings stored in this error log.

This method prints the text to the stream given by the optional parameter stream. If no stream is given, the method prints the output to the standard error stream.

The format of the output is:

   N error(s):
     line NNN: (id) message

If no errors have occurred, i.e., getNumErrors() == 0, then no output will be produced.

Parameters
streamthe ostream or ostringstream object indicating where the output should be printed.
Note
Owing to the way that language interfaces are created in libSBML, this documentation may show methods that define default values for parameters with text that has the form parameter = value. This is not to be intepreted as a Python keyword argument; the use of a parameter name followed by an equals sign followed by a value is only meant to indicate a default value if the argument is not provided at all. It is not a keyword in the Python sense.
def libsbml.SBMLErrorLog.remove (   self,
  errorId 
)

Removes an error having errorId from the SBMLError list.

remove(long   errorId)

Only the first item will be removed if there are multiple errors with the given errorId.

Parameters
errorIdthe error identifier of the error to be removed.
def libsbml.SBMLErrorLog.removeAll (   self,
  errorId 
)

Removes all errors having errorId from the SBMLError list.

removeAll(long   errorId)
Parameters
errorIdthe error identifier of the error to be removed.
def libsbml.XMLErrorLog.setSeverityOverride (   self,
  severity 
)
inherited

Set the severity override.

setSeverityOverride(long severity)
The severity override mechanism in XMLErrorLog is intended to help applications handle error conditions in ways that may be more convenient for those applications. It is possible to use the mechanism to override the severity code of errors logged by libSBML, and even to disable error logging completely. An override stays in effect until the override is changed again by the calling application.
Parameters
severityan override code indicating what to do. If the value is LIBSBML_OVERRIDE_DISABLED (the default setting) all errors logged will be given the severity specified in their usual definition. If the value is LIBSBML_OVERRIDE_WARNING, then all errors will be logged as warnings. If the value is LIBSBML_OVERRIDE_DONT_LOG, no error will be logged, regardless of their severity.
See also
isSeverityOverridden()
getSeverityOverride()
unsetSeverityOverride()
changeErrorSeverity()
def libsbml.XMLErrorLog.toString (   self)
inherited

Writes all errors contained in this log to a string and returns it.

toString()   string

This method uses printErrors() to format the diagnostic messages. Please consult that method for information about the organization of the messages in the string returned by this method.

Returns
a string containing all logged errors and warnings.
See also
printErrors()
def libsbml.XMLErrorLog.unsetSeverityOverride (   self)
inherited

Usets an existing override.

unsetSeverityOverride()
The severity override mechanism in XMLErrorLog is intended to help applications handle error conditions in ways that may be more convenient for those applications. It is possible to use the mechanism to override the severity code of errors logged by libSBML, and even to disable error logging completely. An override stays in effect until the override is changed again by the calling application.
See also
getSeverityOverride()
setSeverityOverride()
isSeverityOverridden()
changeErrorSeverity()