Package mars.assembler.log
Class AssemblerLog
java.lang.Object
mars.assembler.log.AssemblerLog
A log for keeping track of errors occurring during the assembly process, whether during tokenizing, parsing,
 or assembling. While simply throwing an 
AssemblyError would be a valid way to report errors, using this
 log allows multiple LogMessages with varying LogLevels to be recorded in a single pass.
 
 The original version of this class, written by Pete Sanderson, was called ErrorList.
- Author:
- Pete Sanderson, August 2003; Sean Clarke, October 2024
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()Clear all messages from the log.intGet the maximum number of errors which can be produced by a single assembler run.intCount the total number of logged messages, regardless of level.intgetMessageCount(LogLevel level) Count the number of logged messages with a given level.Get the list of all logged messages, regardless of level, in chronological order.booleanDetermine whether the current number of errors logged exceeds the maximum error count, indicating that the assembler should exit as soon as possible.booleanhasMessages(LogLevel level) Determine whether at least one message has been logged with a given level.voidlog(LogLevel level, SourceLocation location, String content) voidlog(LogMessage message) Log a message for the current assembler run.voidlogError(SourceLocation location, String content) voidlogInfo(SourceLocation location, String content) voidlogWarning(SourceLocation location, String content) voidsetMaxErrorCount(int maxErrorCount) Set the maximum number of errors which can be produced by a single assembler run.voidsetOutput(Consumer<LogMessage> output) 
- 
Constructor Details- 
AssemblerLogpublic AssemblerLog()Create a new, emptyAssemblerLog.
 
- 
- 
Method Details- 
clearpublic void clear()Clear all messages from the log.
- 
getMessagesGet the list of all logged messages, regardless of level, in chronological order.- Returns:
- The list of logged messages.
 
- 
getMessageCountpublic int getMessageCount()Count the total number of logged messages, regardless of level.- Returns:
- The number of messages.
 
- 
getMessageCountCount the number of logged messages with a given level.- Parameters:
- level- The level used to filter messages.
- Returns:
- The number of messages whose level is level.
 
- 
hasMessagesDetermine whether at least one message has been logged with a given level. This method is equivalent to the expressiongetMessageCount(level) > 0.- Parameters:
- level- The level used to filter messages.
- Returns:
- trueif at least one message has been logged with level- level, or- falseif no such messages have been logged.
 
- 
getMaxErrorCountpublic int getMaxErrorCount()Get the maximum number of errors which can be produced by a single assembler run.- Returns:
- The maximum number of messages with level LogLevel.ERRORthat can be logged.
 
- 
setMaxErrorCountpublic void setMaxErrorCount(int maxErrorCount) Set the maximum number of errors which can be produced by a single assembler run.- Parameters:
- maxErrorCount- The maximum number of messages with level- LogLevel.ERRORthat can be logged.
 
- 
hasExceededMaxErrorCountpublic boolean hasExceededMaxErrorCount()Determine whether the current number of errors logged exceeds the maximum error count, indicating that the assembler should exit as soon as possible.- Returns:
- trueif the error count exceeds the maxiumm, or- falseotherwise.
- See Also:
 
- 
setOutput
- 
logLog a message for the current assembler run. After this call, the newly logged message is considered to be the last message in chronological order.- Parameters:
- message- The message to log
 
- 
log
- 
logInfo
- 
logWarning
- 
logError
 
-