Modifier and Type | Field and Description |
---|---|
private char[] |
buffer
buffer to store written message until flushing
|
private int |
bufferIndex
location of next character to be written
|
private static String |
HEX_PREFIX
string that prefixes numbers logged in hexadecimal
|
private static char[] |
hexDigitCharacter
map of hexadecimal digit values to their character representations
|
private static Log |
log
log instance used at build time.
|
private static int |
LOG_BITS_IN_HEX_DIGIT
log2 of number of bits represented by a single hexidemimal digit
|
private static int |
LOG_HEX_DIGITS_IN_BYTE
log2 of number of digits in the unsigned hexadecimal
representation of a byte
|
private static int |
MESSAGE_BUFFER_SIZE
characters in the write buffer for the caller's message.
|
private static char |
NEW_LINE_CHAR
new line character.
|
private boolean |
overflow
true if the buffer has overflown |
private static String |
OVERFLOW_MESSAGE
message added when the write buffer has overflown
|
private static char |
OVERFLOW_MESSAGE_FIRST_CHAR |
private static int |
OVERFLOW_SIZE
characters in the overflow message, including the (optional) final
newline
|
private char |
overflowLastChar
The last character that was written by #addToBuffer(char).
|
private static int |
TEMP_BUFFER_SIZE
characters in buffer for building string representations of
longs.
|
private char[] |
tempBuffer
buffer for building string representations of longs
|
private boolean |
threadIdFlag
true if a thread id will be prepended |
Constructor and Description |
---|
Log()
constructor
|
Modifier and Type | Method and Description |
---|---|
private static void |
add(char c)
adds a character to the buffer
|
private static void |
add(String s)
adds a string to the buffer
|
private void |
addToBuffer(char c)
adds a character to the buffer
|
private void |
addToBuffer(String s)
adds a string to the buffer
|
static void |
flush()
flushes the buffer.
|
private void |
flushBuffer()
flushes the buffer
|
private static char[] |
getIntBuffer() |
private static Log |
getLog() |
private char[] |
getTempBuffer() |
static void |
prependThreadId()
Log a thread identifier at the start of the next message flushed.
|
private void |
setThreadIdFlag()
sets the flag so that a thread identifier will be included before
the logged message
|
static void |
write(Address a)
writes an address, in hexadecimal.
|
static void |
write(boolean b)
writes a boolean.
|
static void |
write(byte[] b)
writes an array of bytes.
|
static void |
write(char c)
writes a character
|
static void |
write(char[] c)
writes an array of characters
|
static void |
write(char[] c,
int len)
writes the start of an array of characters
|
static void |
write(double d)
writes a
double . |
static void |
write(double d,
int postDecimalDigits)
writes a
double . |
static void |
write(Extent e)
writes an extent, in hexadecimal.
|
static void |
write(long l)
writes a long, in decimal.
|
static void |
write(ObjectReference o)
writes an object reference, in hexadecimal.
|
static void |
write(Offset o)
writes an offset, in hexadecimal.
|
static void |
write(String s)
writes a string
|
static void |
write(String s,
Address a)
writes a string followed by an address, in hexadecimal.
|
static void |
write(String s,
long l)
Write a string followed by a long
|
static void |
write(Word w)
writes a word, in hexadecimal.
|
static void |
writeDec(Word w)
writes a word, in decimal.
|
private static void |
writeHex(Word w,
int bytes)
writes a
long in hexadecimal |
static void |
writeln()
write a new-line and flushes the buffer
|
static void |
writeln(Address a)
writes an address, in hexadecimal, and a new-line, then flushes
the buffer.
|
static void |
writeln(Address a,
boolean flush)
writes an address, in hexadecimal, and a new-line, then optionally
flushes the buffer.
|
static void |
writeln(boolean b)
writes a boolean and a new-line, then flushes the buffer.
|
static void |
writeln(boolean b,
boolean flush)
writes a boolean and a new-line, then optionally flushes the buffer.
|
static void |
writeln(byte[] b)
writes an array of bytes and a new-line, then
flushes the buffer.
|
static void |
writeln(byte[] b,
boolean flush)
writes an array of bytes and a new-line, then optionally flushes the
buffer.
|
static void |
writeln(char c)
writes a character and a new-line, then flushes the buffer.
|
static void |
writeln(char[] ca)
writes an array of characters and a new-line, then flushes the buffer.
|
static void |
writeln(char[] ca,
boolean flush)
writes an array of characters and a new-line, then optionally
flushes the buffer.
|
static void |
writeln(char[] ca,
int len)
writes the start of an array of characters and a new-line, then
flushes the buffer.
|
static void |
writeln(char[] ca,
int len,
boolean flush)
writes the start of an array of characters and a new-line, then
optionally flushes the buffer.
|
static void |
writeln(char c,
boolean flush)
writes a character and a new-line, then optionally flushes the
buffer.
|
static void |
writeln(double d)
writes a
double and a new-line, then flushes the buffer. |
static void |
writeln(double d,
boolean flush)
writes a
double and a new-line, then optionally flushes
the buffer. |
static void |
writeln(double d,
int postDecimalDigits)
writes a
double and a new-line, then flushes the buffer. |
static void |
writeln(double d,
int postDecimalDigits,
boolean flush)
writes a
double and a new-line, then optionally flushes
the buffer. |
static void |
writeln(Extent e)
writes an extent, in hexadecimal, and a new-line, then flushes the buffer.
|
static void |
writeln(Extent e,
boolean flush)
writes an extent, in hexadecimal, and a new-line, then optionally
flushes the buffer.
|
static void |
writeln(long l)
writes a long, in decimal, and a new-line, then flushes the buffer.
|
static void |
writeln(long l,
boolean flush)
writes a long, in decimal, and a new-line, then optionally flushes
the buffer.
|
static void |
writeln(ObjectReference o)
writes an object reference, in hexadecimal, and a new-line, then
flushes the buffer.
|
static void |
writeln(ObjectReference o,
boolean flush)
writes an object reference, in hexadecimal, and a new-line, then
optionally flushes the buffer.
|
static void |
writeln(Offset o)
writes an offset, in hexadecimal, and a new-line, then flushes the buffer.
|
static void |
writeln(Offset o,
boolean flush)
writes an offset, in hexadecimal, and a new-line, then optionally
flushes the buffer.
|
static void |
writeln(String s)
writes a string and a new-line, then flushes the buffer.
|
static void |
writeln(String s,
Address a)
writes a string followed by a Address
|
static void |
writeln(String s,
boolean flush)
writes a string and a new-line, then optionally flushes the buffer.
|
static void |
writeln(String s,
long l) |
static void |
writeln(Word w)
writes a word, in hexadecimal, and a new-line, then flushes the buffer.
|
static void |
writeln(Word w,
boolean flush)
writes a word, in hexadecimal, and a new-line, then optionally
flushes the buffer.
|
static void |
writelnNoFlush()
writes a new-line without flushing the buffer
|
private static void |
writelnWithFlush(boolean flush)
writes a new-line and optionally flushes the buffer
|
private static final int MESSAGE_BUFFER_SIZE
This needs to be large because Jikes RVM's implementation of Lock.java logs a lot of information when there is potential GC deadlock.
private static final String OVERFLOW_MESSAGE
private static final char OVERFLOW_MESSAGE_FIRST_CHAR
private static final int OVERFLOW_SIZE
private static final int TEMP_BUFFER_SIZE
private static final String HEX_PREFIX
private static final int LOG_BITS_IN_HEX_DIGIT
private static final int LOG_HEX_DIGITS_IN_BYTE
private static final char[] hexDigitCharacter
private static final char NEW_LINE_CHAR
private final char[] buffer
private int bufferIndex
private boolean overflow
true
if the buffer has overflownprivate char overflowLastChar
private boolean threadIdFlag
true
if a thread id will be prependedprivate final char[] tempBuffer
public Log()
public static void write(boolean b)
b
- boolean value to be logged.public static void write(char c)
c
- character to be loggedpublic static void write(long l)
l
- long value to be loggedpublic static void write(double d)
double
. Two digits after the decimal point
are always logged. The value is not padded and no thousands
separator is used. If the value is negative a leading
hyphen-minus (-) is logged. The decimal point is a full stop
(.).d
- the double to be loggedpublic static void write(double d, int postDecimalDigits)
double
. The number of digits after the
decimal point is determined by postDecimalDigits
.
The value is not padded and not thousands separator is used. If
the value is negative a leading hyphen-minus (-) is logged. The
decimal point is a full stop (.) and is logged even if
postDecimcalDigits
is zero. If d
is greater
than the largest representable value of type int
, it
is logged as "TooBig". Similarly, if it is less than
the negative of the largest representable value, it is logged as
"TooSmall". If d
is NaN is is logged as "NaN".d
- the double to be loggedpostDecimalDigits
- the number of digits to be logged after
the decimal point. If less than or equal to zero no digits are
logged, but the decimal point is.public static void write(char[] c)
c
- the array of characters to be loggedpublic static void write(char[] c, int len)
c
- the array of characterslen
- the number of characters to be logged, starting with
the first characterpublic static void write(byte[] b)
b
- the array of bytes to be loggedpublic static void write(Word w)
w
- the word to be loggedpublic static void writeDec(Word w)
w
- the word to be loggedpublic static void write(Address a)
a
- the address to be loggedpublic static void write(String s, Address a)
s
- the string to be loggeda
- the address to be loggedwrite(String)
,
write(Address)
public static void write(String s, long l)
s
- the string to be loggedl
- the long to be loggedwrite(String)
,
write(long)
public static void write(ObjectReference o)
o
- the object reference to be loggedpublic static void write(Offset o)
o
- the offset to be loggedpublic static void write(Extent e)
e
- the extent to be loggedpublic static void writeln()
public static void writeln(boolean b)
b
- boolean value to be logged.write(boolean)
public static void writeln(char c)
c
- character to be loggedwrite(char)
public static void writeln(long l)
l
- long value to be loggedwrite(long)
public static void writeln(double d)
double
and a new-line, then flushes the buffer.d
- the double to be loggedwrite(double)
public static void writeln(double d, int postDecimalDigits)
double
and a new-line, then flushes the buffer.d
- the double to be loggedpostDecimalDigits
- the number of digits to be logged after
the decimal point. If less than or equal to zero no digits are
logged, but the decimal point is.write(double, int)
public static void writeln(char[] ca)
ca
- the array of characters to be loggedwrite(char [])
public static void writeln(char[] ca, int len)
ca
- the array of characterslen
- the number of characters to be logged, starting with
the first characterwrite(char[], int)
public static void writeln(byte[] b)
b
- the array of bytes to be loggedwrite(byte[])
public static void writeln(String s)
s
- the string to be loggedpublic static void writeln(Word w)
w
- the word to be loggedwrite(Word)
public static void writeln(Address a)
a
- the address to be loggedwrite(Address)
public static void writeln(ObjectReference o)
o
- the object reference to be loggedwrite(ObjectReference)
public static void writeln(Offset o)
o
- the offset to be loggedwrite(Offset)
public static void writeln(Extent e)
e
- the extent to be loggedwrite(Extent)
public static void writelnNoFlush()
public static void writeln(boolean b, boolean flush)
b
- boolean value to be logged.flush
- if true
then flushes the bufferwrite(boolean)
public static void writeln(char c, boolean flush)
c
- character to be loggedflush
- if true
then flushes the bufferwrite(char)
public static void writeln(long l, boolean flush)
l
- long value to be loggedflush
- if true
then flushes the bufferwrite(long)
public static void writeln(double d, boolean flush)
double
and a new-line, then optionally flushes
the buffer.d
- the double to be loggedflush
- if true
then flush the bufferwrite(double)
public static void writeln(double d, int postDecimalDigits, boolean flush)
double
and a new-line, then optionally flushes
the buffer.d
- the double to be loggedpostDecimalDigits
- the number of digits to be logged after
the decimal point. If less than or equal to zero no digits are
logged, but the decimal point is.flush
- if true
then flushes the bufferwrite(double, int)
public static void writeln(char[] ca, boolean flush)
ca
- the array of characters to be loggedflush
- if true
then flushes the bufferwrite(char [])
public static void writeln(char[] ca, int len, boolean flush)
ca
- the array of characterslen
- the number of characters to be logged, starting with
the first characterflush
- if true
then flushes the bufferwrite(char[], int)
public static void writeln(byte[] b, boolean flush)
b
- the array of bytes to be loggedflush
- if true
then flushes the bufferwrite(byte[])
public static void writeln(String s, boolean flush)
s
- the string to be loggedflush
- if true
then flushes the bufferpublic static void writeln(Word w, boolean flush)
w
- the word to be loggedflush
- if true
then flushes the bufferwrite(Word)
public static void writeln(Address a, boolean flush)
a
- the address to be loggedflush
- if true
then flushes the bufferwrite(Address)
public static void writeln(ObjectReference o, boolean flush)
o
- the object reference to be loggedflush
- if true
then flushes the bufferwrite(ObjectReference)
public static void writeln(Offset o, boolean flush)
o
- the offset to be loggedflush
- if true
then flushes the bufferwrite(Offset)
public static void writeln(Extent e, boolean flush)
e
- the extent to be loggedflush
- if true
then flushes the bufferwrite(Extent)
public static void writeln(String s, Address a)
s
- the string to be loggeda
- the Address to be loggedwrite(String)
,
write(Address)
public static void prependThreadId()
public static void flush()
private static void writelnWithFlush(boolean flush)
flush
- if true
the buffer is flushedprivate static void writeHex(Word w, int bytes)
long
in hexadecimalw
- the Word to be loggedbytes
- the number of bytes from the long to be logged. If
less than 8 then the least significant bytes are logged and some
of the most significant bytes are ignored.private static void add(char c)
c
- the character to addprivate void addToBuffer(char c)
c
- the character to addprivate void addToBuffer(String s)
s
- the string to addprivate void flushBuffer()
private void setThreadIdFlag()
private static char[] getIntBuffer()
private char[] getTempBuffer()