|
antlraux package v0.2.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--antlraux.util.Logger
This class can be used for maintaining logs. It admits log entries relative to lexical coordinates (a filename, line and column) and non relative entries (no lex info). It also offers other services like tabulation facilities, log count and log deactivation (you can define the minimum level that a message has to have in order to be logged).
Usually you will want to use this class in conjuction with your analizers. In order to do that, you'll have to create your logger and override reportError:
header{ import antlraux.util.Logger; } public class MyParser extends Parser; options {...} tokens {...} // code zone { Logger logger = new Logger(...); // add your params here public void reportError(RecognitionException re) { logger.log( re.getMessage(), re.getFileName(), re.getLine(), re.getColumn() ); } }This works more or less the same way for lexers and treeparsers.
Field Summary | |
protected antlr.FileLineFormatter |
flf
The file line formatter |
protected int |
logCounter
Counter |
protected int |
minLogLevel
Minimum level of the messages (default -1; shows all messages) |
protected java.lang.String |
name
The name of the Logger |
protected java.lang.String |
newLineString
String used for new lines |
protected java.io.OutputStream |
os
The log's output stream |
protected int |
tabLevel
Tabulation level |
protected java.lang.String |
tabString
String used in tabulations |
Constructor Summary | |
Logger(java.lang.String name)
Creates a new logger with a certain name |
|
Logger(java.lang.String name,
java.io.OutputStream os)
Specifies name and output stream |
|
Logger(java.lang.String name,
java.io.OutputStream os,
java.lang.String newLineString,
java.lang.String tabString)
Specifies nearly everything |
|
Logger(java.lang.String name,
java.io.OutputStream os,
java.lang.String newLineString,
java.lang.String tabString,
antlr.FileLineFormatter flf)
Specifies everything |
Method Summary | |
void |
decTabs()
Decrements tabLevel by one unit |
antlr.FileLineFormatter |
getFileLineFormatter()
Accessor for flf |
int |
getLogCounter()
Accessor for logCounter |
int |
getMinLogLevel()
Accessor for minLogLevel |
java.lang.String |
getName()
Accessor for name |
java.lang.String |
getNewLineString()
Accessor for newLineString |
int |
getTabLevel()
Accessor for tabLevel |
java.lang.String |
getTabString()
Accessor for tabString |
void |
incTabs()
Increments tabLevel in one unit |
void |
log(java.lang.String msg,
int msgLevel)
Adds a log with a certain level. |
void |
log(java.lang.String msg,
int msgLevel,
LexInfo li)
A log with lex info |
void |
log(java.lang.String msg,
int msgLevel,
java.lang.String filename,
int line,
int column)
A log with lex info |
void |
newLine()
Prints the string newLineString once on the
Logger's outputStream |
void |
print(java.lang.String msg)
Prints a message to the Logger's output stream |
void |
resetLogCounter()
Makes logCounter =0 |
void |
setFileLineFormatter(antlr.FileLineFormatter flf)
Accessor for flf |
void |
setMinLogLevel(int newMin)
Accessor for minLogLevel |
void |
setNewLineString(java.lang.String s)
Accessor for newLineString |
void |
setOutputStream(java.io.OutputStream newOs)
Accessor for os |
void |
setTabLevel(int t)
Accessor for tabLevel . |
void |
setTabString(java.lang.String ts)
Accessor for tabString |
void |
tabulate()
Prints the string " tabString " tabLevel times
on the Logger's outputStream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int tabLevel
protected int minLogLevel
protected int logCounter
protected java.lang.String name
protected java.lang.String tabString
protected java.lang.String newLineString
protected antlr.FileLineFormatter flf
protected java.io.OutputStream os
Constructor Detail |
public Logger(java.lang.String name)
public Logger(java.lang.String name, java.io.OutputStream os)
public Logger(java.lang.String name, java.io.OutputStream os, java.lang.String newLineString, java.lang.String tabString)
public Logger(java.lang.String name, java.io.OutputStream os, java.lang.String newLineString, java.lang.String tabString, antlr.FileLineFormatter flf)
Method Detail |
public void print(java.lang.String msg)
public void log(java.lang.String msg, int msgLevel)
logCounter
is incremented.
public void log(java.lang.String msg, int msgLevel, java.lang.String filename, int line, int column)
public void log(java.lang.String msg, int msgLevel, LexInfo li)
public void tabulate()
tabString
" tabLevel
times
on the Logger's outputStream.
public void newLine()
newLineString
once on the
Logger's outputStream
public void incTabs()
tabLevel
in one unit
public void decTabs()
tabLevel
by one unit
public int getLogCounter()
logCounter
public void resetLogCounter()
logCounter
=0
public java.lang.String getName()
name
public int getMinLogLevel()
minLogLevel
public void setMinLogLevel(int newMin)
minLogLevel
public int getTabLevel()
tabLevel
public void setTabLevel(int t)
tabLevel
. You should use
incTabs()
and decTabs()
instead of
this method whenever possible.
public java.lang.String getTabString()
tabString
public void setTabString(java.lang.String ts)
tabString
public java.lang.String getNewLineString()
newLineString
public void setNewLineString(java.lang.String s)
newLineString
public antlr.FileLineFormatter getFileLineFormatter()
flf
public void setFileLineFormatter(antlr.FileLineFormatter flf)
flf
public void setOutputStream(java.io.OutputStream newOs)
os
|
antlraux package v0.2.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |