public class Log extends AbstractLog
This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
Modifier and Type | Class and Description |
---|---|
static class |
Log.DeferredDiagnosticHandler
A DiagnosticHandler that can defer some or all diagnostics,
by buffering them for later examination and/or reporting.
|
static class |
Log.DiagnosticHandler
DiagnosticHandler's provide the initial handling for diagnostics.
|
static class |
Log.DiscardDiagnosticHandler
A DiagnosticHandler that discards all diagnostics.
|
static class |
Log.PrefixKind |
static class |
Log.WriterKind |
Modifier and Type | Field and Description |
---|---|
boolean |
compressedOutput
Set to true if a compressed diagnostic is reported
|
protected DiagnosticListener<? super JavaFileObject> |
diagListener
Diagnostic listener, if provided through programmatic
interface to javac (JSR 199).
|
boolean |
dumpOnError
Print stack trace on errors?
|
boolean |
emitWarnings
Switch: emit warning messages.
|
protected PrintWriter |
errWriter |
Set<String> |
expectDiagKeys
Keys for expected diagnostics.
|
static Context.Key<Log> |
logKey
The context key for the log.
|
protected int |
MaxErrors
The maximum number of errors/warnings that are reported.
|
protected int |
MaxWarnings |
boolean |
multipleErrors
Print multiple errors for same source locations.
|
int |
nerrors
The number of errors encountered so far.
|
protected PrintWriter |
noticeWriter |
int |
nwarnings
The number of warnings encountered so far.
|
static Context.Key<PrintWriter> |
outKey
The context key for the output PrintWriter.
|
boolean |
promptOnError
Switch: prompt user on each error.
|
boolean |
suppressNotes
Switch: suppress note messages.
|
protected PrintWriter |
warnWriter |
diags, source, sourceMap
Modifier | Constructor and Description |
---|---|
protected |
Log(Context context)
Construct a log with default settings.
|
protected |
Log(Context context,
PrintWriter defaultWriter)
Construct a log with all output redirected.
|
protected |
Log(Context context,
PrintWriter errWriter,
PrintWriter warnWriter,
PrintWriter noticeWriter)
Construct a log with given I/O redirections.
|
Modifier and Type | Method and Description |
---|---|
JavaFileObject |
currentSourceFile()
Return current sourcefile.
|
protected void |
directError(String key,
Object... args) |
void |
flush()
Flush the logs
|
void |
flush(Log.WriterKind kind) |
static String |
format(String fmt,
Object... args) |
protected int |
getDefaultMaxErrors()
Default value for -Xmaxerrs.
|
protected int |
getDefaultMaxWarnings()
Default value for -Xmaxwarns.
|
DiagnosticFormatter<JCDiagnostic> |
getDiagnosticFormatter()
Get the current diagnostic formatter.
|
static String |
getLocalizedString(String key,
Object... args)
Find a localized string in the resource bundle.
|
PrintWriter |
getWriter(Log.WriterKind kind) |
protected PrintWriter |
getWriterForDiagnosticType(JCDiagnostic.DiagnosticType dt)
Deprecated.
|
boolean |
hasDiagnosticListener() |
void |
initRound(Log other)
Propagate the previous log's information.
|
static Log |
instance(Context context)
Get the Log instance for this context.
|
String |
localize(Log.PrefixKind pk,
String key,
Object... args)
Find a localized string in the resource bundle.
|
String |
localize(String key,
Object... args)
Find a localized string in the resource bundle.
|
void |
popDiagnosticHandler(Log.DiagnosticHandler h)
Replace the specified diagnostic handler with the
handler that was current at the time this handler was created.
|
void |
printLines(Log.PrefixKind pk,
String key,
Object... args) |
void |
printLines(Log.WriterKind wk,
Log.PrefixKind pk,
String key,
Object... args) |
void |
printLines(Log.WriterKind wk,
String key,
Object... args) |
void |
printLines(String key,
Object... args) |
void |
printNewline() |
void |
printNewline(Log.WriterKind wk) |
void |
printRawLines(Log.WriterKind kind,
String msg)
Print the text of a message, translating newlines appropriately
for the platform.
|
static void |
printRawLines(PrintWriter writer,
String msg)
Print the text of a message, translating newlines appropriately
for the platform.
|
void |
printRawLines(String msg)
Print the text of a message, translating newlines appropriately
for the platform.
|
void |
printVerbose(String key,
Object... args)
Print the localized text of a "verbose" message to the
noticeWriter stream.
|
void |
prompt()
Prompt user after an error.
|
void |
rawError(int pos,
String msg)
report an error:
|
void |
rawWarning(int pos,
String msg)
report a warning:
|
void |
report(JCDiagnostic diagnostic)
Primary method to report a diagnostic.
|
void |
setDiagnosticFormatter(DiagnosticFormatter<JCDiagnostic> diagFormatter)
Set the current diagnostic formatter.
|
void |
setEndPosTable(JavaFileObject name,
EndPosTable endPosTable) |
void |
setWriter(Log.WriterKind kind,
PrintWriter pw) |
void |
setWriters(PrintWriter pw) |
protected boolean |
shouldReport(JavaFileObject file,
int pos)
Returns true if an error needs to be reported for a given
source name and pos.
|
void |
strictWarning(JCDiagnostic.DiagnosticPosition pos,
String key,
Object... args)
Report a warning that cannot be suppressed.
|
protected void |
writeDiagnostic(JCDiagnostic diag)
Write out a diagnostic.
|
currentSource, error, error, error, error, error, getSource, mandatoryNote, mandatoryWarning, mandatoryWarning, note, note, note, note, useSource, warning, warning, warning, warning, warning
public static final Context.Key<Log> logKey
public static final Context.Key<PrintWriter> outKey
protected PrintWriter errWriter
protected PrintWriter warnWriter
protected PrintWriter noticeWriter
protected int MaxErrors
protected int MaxWarnings
public boolean promptOnError
public boolean emitWarnings
public boolean suppressNotes
public boolean dumpOnError
public boolean multipleErrors
protected DiagnosticListener<? super JavaFileObject> diagListener
public boolean compressedOutput
public int nerrors
public int nwarnings
protected Log(Context context, PrintWriter errWriter, PrintWriter warnWriter, PrintWriter noticeWriter)
protected Log(Context context)
protected Log(Context context, PrintWriter defaultWriter)
protected int getDefaultMaxErrors()
protected int getDefaultMaxWarnings()
public boolean hasDiagnosticListener()
public void setEndPosTable(JavaFileObject name, EndPosTable endPosTable)
public JavaFileObject currentSourceFile()
public DiagnosticFormatter<JCDiagnostic> getDiagnosticFormatter()
public void setDiagnosticFormatter(DiagnosticFormatter<JCDiagnostic> diagFormatter)
public PrintWriter getWriter(Log.WriterKind kind)
public void setWriter(Log.WriterKind kind, PrintWriter pw)
public void setWriters(PrintWriter pw)
public void initRound(Log other)
public void popDiagnosticHandler(Log.DiagnosticHandler h)
public void flush()
public void flush(Log.WriterKind kind)
protected boolean shouldReport(JavaFileObject file, int pos)
public void prompt()
public void printNewline()
public void printNewline(Log.WriterKind wk)
public void printLines(Log.PrefixKind pk, String key, Object... args)
public void printLines(Log.WriterKind wk, String key, Object... args)
public void printLines(Log.WriterKind wk, Log.PrefixKind pk, String key, Object... args)
public void printRawLines(String msg)
public void printRawLines(Log.WriterKind kind, String msg)
public static void printRawLines(PrintWriter writer, String msg)
public void printVerbose(String key, Object... args)
protected void directError(String key, Object... args)
directError
in class AbstractLog
public void strictWarning(JCDiagnostic.DiagnosticPosition pos, String key, Object... args)
pos
- The source position at which to report the warning.key
- The key for the localized warning message.args
- Fields of the warning message.public void report(JCDiagnostic diagnostic)
report
in class AbstractLog
diagnostic
- protected void writeDiagnostic(JCDiagnostic diag)
@Deprecated protected PrintWriter getWriterForDiagnosticType(JCDiagnostic.DiagnosticType dt)
public static String getLocalizedString(String key, Object... args)
key
- The key for the localized string.args
- Fields to substitute into the string.public String localize(String key, Object... args)
key
- The key for the localized string.args
- Fields to substitute into the string.public String localize(Log.PrefixKind pk, String key, Object... args)
key
- The key for the localized string.args
- Fields to substitute into the string.public void rawError(int pos, String msg)
public void rawWarning(int pos, String msg)
Copyright © 2015. All rights reserved.