Skip to content

Package io.github.qishr.cascara.common.diagnostic.report

Class AbstractReporter

java.lang.Object
        io.github.qishr.cascara.common.diagnostic.report.AbstractReporter

All Implemented Interfaces:
    Reporter

Direct Known Subtypes:
    SilentCollectingReporter, LocalReporter, GlobalReporter


public abstract class AbstractReporter

Field Summary

Modifier and Type Field Description
protected static final ZoneId UTC
protected boolean ansiColoringEnabled
protected ConsoleLogger consoleLogger
protected Consumer diagnosticConsumer Consumes diagnostics included in the current Level or more important, with ERROR being the most important.
protected boolean flushEnabled
protected FormatOptions formatOptions
protected Level level
protected LineLogger lineLogger
protected List loggers
protected Consumer problemConsumer Consumes ERROR, WARN, and INFO diagnostics.
protected Serializer<?> serializer
protected String source The simple name of the class that made the report
protected boolean systemErrorEnabled
protected boolean systemOutputEnabled
protected ReportWriter[] writers

Constructor Summary

Constructor Description
AbstractReporter()

Method Summary

Modifier and Type Method Description
protected abstract T self()
protected FormatOptions defaultFormatOptions() To be overridden by reporters neding specific default options
public T addLogger(Logger logger)
public Level getLevel()
public T setLevel(Level level) Sets the level of output when logging directly to the console.
public T setLineConsumer(Consumer<String> consumer)
protected java.util.function.@io.github.qishr.cascara.common.annotation.Experimental Consumer<Diagnostic> getDiagnosticConsumer()
public T setDiagnosticConsumer(Consumer<Diagnostic> consumer) Registers a consumer to receive all diagnostics processed by this reporter.
protected java.util.function.@io.github.qishr.cascara.common.annotation.Experimental Consumer<Diagnostic> getProblemConsumer()
public T setProblemConsumer(Consumer<Diagnostic> consumer) Registers a consumer to receive only problem-level diagnostics.
public @io.github.qishr.cascara.common.annotation.Experimental boolean collectsProblems() Checks whether any active consumer is collecting problems.
public T setStackTraceEnabled(boolean b)
public T setPrefixEveryLine(boolean b)
public T setShowProblemCodes(boolean b)
protected boolean isSystemOutputEnabled()
public T setSystemOutputEnabled(boolean b) Controls whether diagnostic logging to console is enabled.
protected boolean isImmediateFlushEnabled()
public T setImmediateFlushEnabled(boolean b) Controls whether diagnostics logged to console are flushed immediately.
public T setSystemErrorEnabled(boolean b) Controls whether errors logged to console go to System.out or System.err.
public T setAnsiColoringEnabled(boolean b) Controls whether diagnostics logged to console use ANSI coloring.
public boolean isSilent()
public boolean reportsDebug()
public boolean reportsTrace()
public ReportWriter getWriter(Level level)
public void error(Exception e) Reports an Exception
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(DiagnosticMessage message, Object[] details) Reports an informational message through the reporter.
public void warn(DiagnosticMessage message, Object[] details) Reports a warning message including location information.
public void error(DiagnosticMessage message, Object[] details) Reports an error message including location information.
public void error(Throwable cause, DiagnosticMessage message, Object[] details) Reports an error message including location information.
public void infoAt(int line, int column, DiagnosticMessage message, Object[] details) Reports an informational message anchored to a resource location by line and column.
public void warnAt(int line, int column, DiagnosticMessage message, Object[] details) Reports a warning anchored to a resource location by line and column.
public void errorAt(int line, int column, DiagnosticMessage message, Object[] details) Reports an error anchored to a resource location by line and column.
public void errorAt(int line, int column, Throwable cause, DiagnosticMessage message, 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, DiagnosticMessage message, 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, DiagnosticMessage message, 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, DiagnosticMessage message, 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, DiagnosticMessage message, Object[] details) Reports an error anchored to a precise character span within a resource.
public void infoAt(Token token, DiagnosticMessage message, Object[] details) Reports an informational message derived from the location attributes of a structural token.
public void warnAt(Token token, DiagnosticMessage message, Object[] details) Reports a warning derived from the location attributes of a structural token.
public void errorAt(Token token, DiagnosticMessage message, Object[] details) Reports an error derived from the location attributes of a structural token.
public void errorAt(Token token, Throwable cause, DiagnosticMessage message, Object[] details) Reports an error derived from the location attributes of a structural token.
public void warnAt(URI uri, int line, int column, DiagnosticMessage message, Object[] details)
public void errorAt(URI uri, int line, int column, DiagnosticMessage message, Object[] details)
public void warnAt(URI uri, Token token, DiagnosticMessage message, Object[] details)
public void errorAt(URI uri, Token token, DiagnosticMessage message, Object[] details)
public void errorAt(URI uri, Token token, Throwable cause, DiagnosticMessage message, Object[] details)
protected void report(Diagnostic diagnostic) Central reporting method.
protected void reportAnyLevel(Diagnostic diagnostic)
protected void log(Diagnostic diagnostic)
protected void logLine(Level level, String msgLine) Used by LogWriter to log lines of text
protected boolean isProblem(Level level)

Field Details

UTC

protected static final ZoneId UTC


ansiColoringEnabled

protected boolean ansiColoringEnabled


consoleLogger

protected ConsoleLogger consoleLogger


diagnosticConsumer

protected Consumer diagnosticConsumer

Consumes diagnostics included in the current Level or more important, with ERROR being the most important.


flushEnabled

protected boolean flushEnabled


formatOptions

protected FormatOptions formatOptions


level

protected Level level


lineLogger

protected LineLogger lineLogger


loggers

protected List loggers


problemConsumer

protected Consumer problemConsumer

Consumes ERROR, WARN, and INFO diagnostics.


serializer

protected Serializer<?> serializer


source

protected String source

The simple name of the class that made the report


systemErrorEnabled

protected boolean systemErrorEnabled


systemOutputEnabled

protected boolean systemOutputEnabled


writers

protected ReportWriter[] writers


Method Details

self

protected abstract T self()


defaultFormatOptions

protected FormatOptions defaultFormatOptions()

To be overridden by reporters neding specific default options


addLogger

public T addLogger(Logger logger)


getLevel

public Level getLevel()

Specified By:

Reporter


setLevel

public T setLevel(Level level)

Sets the level of output when logging directly to the console.

Specified By:

Reporter


setLineConsumer

@io.github.qishr.cascara.common.annotation.Experimental
public T setLineConsumer(Consumer<String> consumer)

Specified By:

Reporter


getDiagnosticConsumer

@io.github.qishr.cascara.common.annotation.Experimental
protected java.util.function.@io.github.qishr.cascara.common.annotation.Experimental Consumer<Diagnostic> getDiagnosticConsumer()


setDiagnosticConsumer

@io.github.qishr.cascara.common.annotation.Experimental
public T setDiagnosticConsumer(Consumer<Diagnostic> consumer)

Registers a consumer to receive all diagnostics processed by this reporter.

Specified By:

Reporter


getProblemConsumer

@io.github.qishr.cascara.common.annotation.Experimental
protected java.util.function.@io.github.qishr.cascara.common.annotation.Experimental Consumer<Diagnostic> getProblemConsumer()


setProblemConsumer

@io.github.qishr.cascara.common.annotation.Experimental
public T setProblemConsumer(Consumer<Diagnostic> consumer)

Registers a consumer to receive only problem-level diagnostics.

Specified By:

Reporter


collectsProblems

@io.github.qishr.cascara.common.annotation.Experimental
public @io.github.qishr.cascara.common.annotation.Experimental boolean collectsProblems()

Checks whether any active consumer is collecting problems.

Specified By:

Reporter


setStackTraceEnabled

public T setStackTraceEnabled(boolean b)


setPrefixEveryLine

@io.github.qishr.cascara.common.annotation.Experimental
public T setPrefixEveryLine(boolean b)


setShowProblemCodes

public T setShowProblemCodes(boolean b)


isSystemOutputEnabled

protected boolean isSystemOutputEnabled()


setSystemOutputEnabled

public T setSystemOutputEnabled(boolean b)

Controls whether diagnostic logging to console is enabled.


isImmediateFlushEnabled

protected boolean isImmediateFlushEnabled()


setImmediateFlushEnabled

public T setImmediateFlushEnabled(boolean b)

Controls whether diagnostics logged to console are flushed immediately.


setSystemErrorEnabled

public T setSystemErrorEnabled(boolean b)

Controls whether errors logged to console go to System.out or System.err.


setAnsiColoringEnabled

public T setAnsiColoringEnabled(boolean b)

Controls whether diagnostics logged to console use ANSI coloring.


isSilent

public boolean isSilent()

Specified By:

Reporter


reportsDebug

public boolean reportsDebug()

Specified By:

Reporter


reportsTrace

public boolean reportsTrace()

Specified By:

Reporter


getWriter

public ReportWriter getWriter(Level level)

Specified By:

Reporter


error

public void error(Exception e)

Reports an Exception

Specified By:

Reporter


trace

public void trace(String message, Object[] details)

Reports a trace message through the reporter.

Specified By:

Reporter


debug

public void debug(String message, Object[] details)

Reports a debug message through the reporter.

Specified By:

Reporter


info

public void info(DiagnosticMessage message, Object[] details)

Reports an informational message through the reporter.

Specified By:

Reporter


warn

public void warn(DiagnosticMessage message, Object[] details)

Reports a warning message including location information.

Specified By:

Reporter


error

public void error(DiagnosticMessage message, Object[] details)

Reports an error message including location information.

Specified By:

Reporter


error

public void error(Throwable cause, DiagnosticMessage message, Object[] details)

Reports an error message including location information.

Specified By:

Reporter


infoAt

public void infoAt(int line, int column, DiagnosticMessage message, Object[] details)

Reports an informational message anchored to a resource location by line and column.

Specified By:

Reporter


warnAt

public void warnAt(int line, int column, DiagnosticMessage message, Object[] details)

Reports a warning anchored to a resource location by line and column.

Specified By:

Reporter


errorAt

public void errorAt(int line, int column, DiagnosticMessage message, Object[] details)

Reports an error anchored to a resource location by line and column.

Specified By:

Reporter


errorAt

public void errorAt(int line, int column, Throwable cause, DiagnosticMessage message, Object[] details)

Reports an error anchored to a resource location by line and column.

Specified By:

Reporter


infoAt

public void infoAt(int line, int column, int startOffset, int endOffset, DiagnosticMessage message, Object[] details)

Reports an informational message anchored to a precise character span within a resource.

Specified By:

Reporter


warnAt

public void warnAt(int line, int column, int startOffset, int endOffset, DiagnosticMessage message, Object[] details)

Reports a warning anchored to a precise character span within a resource.

Specified By:

Reporter


errorAt

public void errorAt(int line, int column, int startOffset, int endOffset, DiagnosticMessage message, Object[] details)

Reports an error anchored to a precise character span within a resource.

Specified By:

Reporter


errorAt

public void errorAt(int line, int column, int startOffset, int endOffset, Throwable cause, DiagnosticMessage message, Object[] details)

Reports an error anchored to a precise character span within a resource.

Specified By:

Reporter


infoAt

public void infoAt(Token token, DiagnosticMessage message, Object[] details)

Reports an informational message derived from the location attributes of a structural token.

Specified By:

Reporter


warnAt

public void warnAt(Token token, DiagnosticMessage message, Object[] details)

Reports a warning derived from the location attributes of a structural token.

Specified By:

Reporter


errorAt

public void errorAt(Token token, DiagnosticMessage message, Object[] details)

Reports an error derived from the location attributes of a structural token.

Specified By:

Reporter


errorAt

public void errorAt(Token token, Throwable cause, DiagnosticMessage message, Object[] details)

Reports an error derived from the location attributes of a structural token.

Specified By:

Reporter


warnAt

public void warnAt(URI uri, int line, int column, DiagnosticMessage message, Object[] details)

Specified By:

Reporter


errorAt

public void errorAt(URI uri, int line, int column, DiagnosticMessage message, Object[] details)

Specified By:

Reporter


warnAt

public void warnAt(URI uri, Token token, DiagnosticMessage message, Object[] details)

Specified By:

Reporter


errorAt

public void errorAt(URI uri, Token token, DiagnosticMessage message, Object[] details)

Specified By:

Reporter


errorAt

public void errorAt(URI uri, Token token, Throwable cause, DiagnosticMessage message, Object[] details)

Specified By:

Reporter


report

protected void report(Diagnostic diagnostic)

Central reporting method.All other rporting methods call this.


reportAnyLevel

protected void reportAnyLevel(Diagnostic diagnostic)


log

protected void log(Diagnostic diagnostic)


logLine

protected void logLine(Level level, String msgLine)

Used by LogWriter to log lines of text


isProblem

protected boolean isProblem(Level level)