Package io.github.qishr.cascara.common.diagnostic
Class AbstractReporter
java.lang.Object
io.github.qishr.cascara.common.diagnostic.AbstractReporter
All Implemented Interfaces:
Reporter
Direct Known Subtypes:
SilentCollectingReporter, GlobalReporter, StandardReporter
public abstract class AbstractReporter
Field Summary
| Modifier and Type | Field | Description |
|---|---|---|
| protected Consumer |
diagnosticCollector | Consumes diagnostics included in the current Level or more important, with ERROR being the most important. |
| protected boolean | flushEnabled | |
| protected Level | level | |
| protected Consumer |
problemCollector | Consumes ERROR, WARN, and INFO diagnostics. |
| protected String | source | The simple name of the class that made the report |
| protected boolean | stackTraceEnabled | |
| protected Consumer |
stringWriter | |
| protected boolean | systemErrorEnabled | |
| protected boolean | systemOutputEnabled |
Constructor Summary
| Constructor | Description |
|---|---|
| AbstractReporter(Consumer<String> writer) | |
| AbstractReporter() |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
| protected abstract T | self() | |
| public boolean | collectsProblems() | Checks whether any active listener or collector is tracking problems. |
| public T | setLevel(Level level) | Sets the level of output when logging directly to the console. |
| public T | setDiagnosticCollector(Consumer<Diagnostic> collector) | Registers a collector to receive all diagnostics processed by this reporter. |
| public T | setProblemCollector(Consumer<Diagnostic> collector) | Registers a specialized collector to receive only problem-level diagnostics. |
| public T | setSystemOutputEnabled(boolean b) | |
| public T | setFlushEnabled(boolean b) | |
| public T | setStackTraceEnabled(boolean b) | |
| public T | setSystemErrorEnabled(boolean b) | |
| public Level | getLevel() | |
| public boolean | isSilent() | |
| public void | error(LocalizableException e) | Reports a LocalizableException |
| public void | error(LocalizableRuntimeException e) | Reports a LocalizableRuntimeException |
| public void | trace(String message, Object[] details) | Reports a trace message through the reporter. |
| public void | debug(String message, Object[] details) | Reports a debug message through the reporter. |
| public void | info(DiagnosticCode code, Object[] details) | Reports an informational message through the reporter. |
| public void | warn(DiagnosticCode code, Object[] details) | Reports a warning message including location information. |
| public void | error(DiagnosticCode code, Object[] details) | Reports an error message including location information. |
| public void | error(Throwable cause, DiagnosticCode code, Object[] details) | Reports an error message including location information. |
| public void | infoAt(int line, int column, DiagnosticCode code, Object[] details) | Reports an informational message anchored to a resource location by line and column. |
| public void | warnAt(int line, int column, DiagnosticCode code, Object[] details) | Reports a warning anchored to a resource location by line and column. |
| public void | errorAt(int line, int column, DiagnosticCode code, Object[] details) | Reports an error anchored to a resource location by line and column. |
| public void | errorAt(URI uri, int line, int column, DiagnosticCode code, Object[] details) | |
| public void | errorAt(int line, int column, Throwable cause, DiagnosticCode code, Object[] details) | Reports an error anchored to a resource location by line and column. |
| public void | infoAt(int line, int column, int startOffset, int endOffset, DiagnosticCode code, Object[] details) | Reports an informational message anchored to a precise character span within a resource. |
| public void | warnAt(int line, int column, int startOffset, int endOffset, DiagnosticCode code, Object[] details) | Reports a warning anchored to a precise character span within a resource. |
| public void | errorAt(int line, int column, int startOffset, int endOffset, DiagnosticCode code, Object[] details) | Reports an error anchored to a precise character span within a resource. |
| public void | errorAt(int line, int column, int startOffset, int endOffset, Throwable cause, DiagnosticCode code, Object[] details) | Reports an error anchored to a precise character span within a resource. |
| public void | infoAt(Token token, DiagnosticCode code, Object[] details) | Reports an informational message derived from the location attributes of a structural token. |
| public void | warnAt(Token token, DiagnosticCode code, Object[] details) | Reports a warning derived from the location attributes of a structural token. |
| public void | errorAt(Token token, DiagnosticCode code, Object[] details) | Reports an error derived from the location attributes of a structural token. |
| public void | errorAt(Token token, Throwable cause, DiagnosticCode code, Object[] details) | Reports an error derived from the location attributes of a structural token. |
| protected abstract void | writeString(Diagnostic diagnostic) | |
| protected Consumer<Diagnostic> | getDiagnosticCollector() | |
| protected Consumer<Diagnostic> | getProblemCollector() | |
| protected Consumer<String> | getStringWriter() | |
| protected boolean | isSystemOutputEnabled() | |
| protected boolean | isFlushEnabled() | |
| protected boolean | isStackTraceEnabled() | |
| protected void | report(Diagnostic diagnostic) | |
| protected void | writeString(Throwable cause, Level level, String message) | |
| protected void | outputToConsole(Throwable cause, Level level, String message) | |
| protected Diagnostic | buildDiagnostic(String source, Level level, String message, Object[] details) | With message string |
| protected Diagnostic | buildDiagnostic(String source, Level level, Throwable cause, DiagnosticCode code, Object[] details) | With diagnostic code, and cause |
| protected Diagnostic | buildDiagnostic(URI uri, int line, int column, int startOffset, int endOffset, String source, Level level, Throwable cause, DiagnosticCode code, Object[] details) | With diagnostic code, location, and cause |
| protected Diagnostic | buildDiagnostic(Token token, String source, Level level, Throwable cause, DiagnosticCode code, Object[] details) | With diagnostic code, token, and cause |
| protected boolean | isProblem(Level level) |
Field Details
diagnosticCollector
protected Consumer
Consumes diagnostics included in the current Level or more important, with ERROR being the most important.
flushEnabled
protected boolean flushEnabled
level
protected Level level
problemCollector
protected Consumer
Consumes ERROR, WARN, and INFO diagnostics.
source
protected String source
The simple name of the class that made the report
stackTraceEnabled
protected boolean stackTraceEnabled
stringWriter
protected Consumer
systemErrorEnabled
protected boolean systemErrorEnabled
systemOutputEnabled
protected boolean systemOutputEnabled
Method Details
self
protected abstract T self()
collectsProblems
public boolean collectsProblems()
Checks whether any active listener or collector is tracking problems.
Specified By:
setLevel
public T setLevel(Level level)
Sets the level of output when logging directly to the console.
Specified By:
setDiagnosticCollector
public T setDiagnosticCollector(Consumer<Diagnostic> collector)
Registers a collector to receive all diagnostics processed by this reporter.
Specified By:
setProblemCollector
public T setProblemCollector(Consumer<Diagnostic> collector)
Registers a specialized collector to receive only problem-level diagnostics.
Specified By:
setSystemOutputEnabled
public T setSystemOutputEnabled(boolean b)
setFlushEnabled
public T setFlushEnabled(boolean b)
setStackTraceEnabled
public T setStackTraceEnabled(boolean b)
setSystemErrorEnabled
public T setSystemErrorEnabled(boolean b)
getLevel
public Level getLevel()
Specified By:
isSilent
public boolean isSilent()
Specified By:
error
public void error(LocalizableException e)
Reports a LocalizableException
Specified By:
error
public void error(LocalizableRuntimeException e)
Reports a LocalizableRuntimeException
Specified By:
trace
public void trace(String message, Object[] details)
Reports a trace message through the reporter.
Specified By:
debug
public void debug(String message, Object[] details)
Reports a debug message through the reporter.
Specified By:
info
public void info(DiagnosticCode code, Object[] details)
Reports an informational message through the reporter.
Specified By:
warn
public void warn(DiagnosticCode code, Object[] details)
Reports a warning message including location information.
Specified By:
error
public void error(DiagnosticCode code, Object[] details)
Reports an error message including location information.
Specified By:
error
public void error(Throwable cause, DiagnosticCode code, Object[] details)
Reports an error message including location information.
Specified By:
infoAt
public void infoAt(int line, int column, DiagnosticCode code, Object[] details)
Reports an informational message anchored to a resource location by line and column.
Specified By:
warnAt
public void warnAt(int line, int column, DiagnosticCode code, Object[] details)
Reports a warning anchored to a resource location by line and column.
Specified By:
errorAt
public void errorAt(int line, int column, DiagnosticCode code, Object[] details)
Reports an error anchored to a resource location by line and column.
Specified By:
errorAt
public void errorAt(URI uri, int line, int column, DiagnosticCode code, Object[] details)
Specified By:
errorAt
public void errorAt(int line, int column, Throwable cause, DiagnosticCode code, Object[] details)
Reports an error anchored to a resource location by line and column.
Specified By:
infoAt
public void infoAt(int line, int column, int startOffset, int endOffset, DiagnosticCode code, Object[] details)
Reports an informational message anchored to a precise character span within a resource.
Specified By:
warnAt
public void warnAt(int line, int column, int startOffset, int endOffset, DiagnosticCode code, Object[] details)
Reports a warning anchored to a precise character span within a resource.
Specified By:
errorAt
public void errorAt(int line, int column, int startOffset, int endOffset, DiagnosticCode code, Object[] details)
Reports an error anchored to a precise character span within a resource.
Specified By:
errorAt
public void errorAt(int line, int column, int startOffset, int endOffset, Throwable cause, DiagnosticCode code, Object[] details)
Reports an error anchored to a precise character span within a resource.
Specified By:
infoAt
public void infoAt(Token token, DiagnosticCode code, Object[] details)
Reports an informational message derived from the location attributes of a structural token.
Specified By:
warnAt
public void warnAt(Token token, DiagnosticCode code, Object[] details)
Reports a warning derived from the location attributes of a structural token.
Specified By:
errorAt
public void errorAt(Token token, DiagnosticCode code, Object[] details)
Reports an error derived from the location attributes of a structural token.
Specified By:
errorAt
public void errorAt(Token token, Throwable cause, DiagnosticCode code, Object[] details)
Reports an error derived from the location attributes of a structural token.
Specified By:
writeString
protected abstract void writeString(Diagnostic diagnostic)
getDiagnosticCollector
protected Consumer<Diagnostic> getDiagnosticCollector()
getProblemCollector
protected Consumer<Diagnostic> getProblemCollector()
getStringWriter
protected Consumer<String> getStringWriter()
isSystemOutputEnabled
protected boolean isSystemOutputEnabled()
isFlushEnabled
protected boolean isFlushEnabled()
isStackTraceEnabled
protected boolean isStackTraceEnabled()
report
protected void report(Diagnostic diagnostic)
writeString
protected void writeString(Throwable cause, Level level, String message)
outputToConsole
protected void outputToConsole(Throwable cause, Level level, String message)
buildDiagnostic
protected Diagnostic buildDiagnostic(String source, Level level, String message, Object[] details)
With message string
buildDiagnostic
protected Diagnostic buildDiagnostic(String source, Level level, Throwable cause, DiagnosticCode code, Object[] details)
With diagnostic code, and cause
buildDiagnostic
protected Diagnostic buildDiagnostic(URI uri, int line, int column, int startOffset, int endOffset, String source, Level level, Throwable cause, DiagnosticCode code, Object[] details)
With diagnostic code, location, and cause
buildDiagnostic
protected Diagnostic buildDiagnostic(Token token, String source, Level level, Throwable cause, DiagnosticCode code, Object[] details)
With diagnostic code, token, and cause
isProblem
protected boolean isProblem(Level level)