public abstract class Log extends Object implements AutoCloseable
Log
object they are invoked on, so that output of multiple values
can be chained. A typical usage looks like the following:
import static com.oracle.svm.core.log.Log.*; void foo(int i, String s) { log().string("i: ").signed(i).string(" s: ").string(s).newline(); }This class implements AutoCloseable, not because the log ever gets "closed", but so it can be used to bracket several lines of logging with a try-with-resources statement, e.g.,
try (final Log trace = Log.log()) { trace.string("[in myMethod(arg: ".signed(arg).string(")").newline(); trace.string(" i: ").signed(i); trace.string(" j: ").signed(j); trace.string("]").newline(); }
Modifier and Type | Field and Description |
---|---|
static int |
LEFT_ALIGN |
static int |
NO_ALIGN |
static int |
RIGHT_ALIGN |
Modifier | Constructor and Description |
---|---|
protected |
Log() |
Modifier and Type | Method and Description |
---|---|
abstract Log |
autoflush(boolean onOrOff)
Turn auto-flushing of the log at every newline on or off.
|
abstract Log |
bool(boolean value)
Prints the strings "true" or "false" depending on the value.
|
abstract Log |
character(char value)
Prints the provided character.
|
void |
close()
An implementation of AutoCloseable.close().
|
Log |
exception(Throwable t)
Prints the provided exception, including a stack trace if available, followed by a newline.
|
abstract Log |
exception(Throwable t,
int maxFrames)
Prints the provided exception, including a stack trace if available, with at most the
specified number of frames, followed by a newline.
|
static void |
finalizeDefaultLogHandler(org.graalvm.nativeimage.LogHandler handler)
If
ImageSingletons.contains(java.lang.Class<?>) returns false for LogHandler.class , then
this method installs a FunctionPointerLogHandler that delegates to handler . |
abstract Log |
flush()
Forces the log to flush to its destination.
|
abstract Log |
hex(int value)
Prints the value, treated as an unsigned value, in hexadecimal format.
|
abstract Log |
hex(long value)
Prints the value, treated as an unsigned value, in hexadecimal format.
|
abstract Log |
hex(org.graalvm.word.WordBase value)
Prints the value, treated as an unsigned value, in hexadecimal format.
|
abstract Log |
hexdump(org.graalvm.word.PointerBase from,
int wordSize,
int numWords)
Prints a hexdump.
|
Log |
indent(boolean addOrRemove)
Change current amount of indentation, and then print a newline.
|
abstract boolean |
isEnabled()
Is this log enabled?
|
static Log |
log()
Return the singleton RealLog instance.
|
static PrintStream |
logStream()
Returns the
Log.log() wrapped as a PrintStream . |
abstract Log |
newline()
Prints the newline character.
|
static Log |
noopLog()
Return the singleton NoopLog instance.
|
abstract Log |
number(long value,
int radix,
boolean signed)
Prints the value according according to the given format specification.
|
abstract Log |
object(Object value)
Simulates java.lang.String.valueOf(Object obj), but without the call to hashCode().
|
abstract Log |
rational(long numerator,
long denominator,
long decimals) |
abstract Log |
redent(boolean addOrRemove)
Change current amount of indentation.
|
static void |
setLog(RealLog realLog)
Set the singleton RealLog instance (only possible during native image generation).
|
abstract Log |
signed(int value)
Prints the value, treated as a signed value, in decimal format.
|
abstract Log |
signed(long value)
Prints the value, treated as a signed value, in decimal format.
|
abstract Log |
signed(org.graalvm.word.WordBase value)
Prints the value, treated as a signed value, in decimal format.
|
abstract Log |
spaces(int value)
Prints the requested number of spaces, e.g., for indentation.
|
Log |
string(byte[] value)
Prints all bytes in the array, without any conversion.
|
abstract Log |
string(byte[] value,
int offset,
int length)
Prints the provided range of bytes in the array, without any conversion.
|
abstract Log |
string(org.graalvm.nativeimage.c.type.CCharPointer value)
Prints the C string.
|
abstract Log |
string(char[] value)
Prints all characters in the array, without any platform- or charset-depending conversions.
|
abstract Log |
string(String value)
Prints all characters in the string, without any platform- or charset-depending conversions.
|
abstract Log |
string(String str,
int fill,
int align)
Prints all characters in the string, filling with spaces before or after.
|
abstract Log |
unsigned(int value)
Prints the value, treated as an unsigned value, in decimal format.
|
abstract Log |
unsigned(long value)
Prints the value, treated as an unsigned value, in decimal format.
|
abstract Log |
unsigned(long value,
int fill,
int align)
Prints the value, treated as an unsigned value, filing spaces before or after.
|
abstract Log |
unsigned(org.graalvm.word.WordBase value)
Prints the value, treated as an unsigned value, in decimal format.
|
abstract Log |
unsigned(org.graalvm.word.WordBase value,
int fill,
int align)
Prints the value, treated as an unsigned value, filing spaces before or after.
|
abstract Log |
zhex(byte value)
Prints the value, treated as an unsigned value, in hexadecimal format zero filled to
2-digits.
|
abstract Log |
zhex(int value)
Prints the value, treated as an unsigned value, in hexadecimal format zero filled to
8-digits.
|
abstract Log |
zhex(long value)
Prints the value, treated as an unsigned value, in hexadecimal format zero filled to
16-digits.
|
abstract Log |
zhex(short value)
Prints the value, treated as an unsigned value, in hexadecimal format zero filled to
4-digits.
|
public static final int NO_ALIGN
public static final int LEFT_ALIGN
public static final int RIGHT_ALIGN
public static void finalizeDefaultLogHandler(org.graalvm.nativeimage.LogHandler handler)
ImageSingletons.contains(java.lang.Class<?>)
returns false
for LogHandler.class
, then
this method installs a FunctionPointerLogHandler
that delegates to handler
.public static void setLog(RealLog realLog)
public static Log log()
public static PrintStream logStream()
Log.log()
wrapped as a PrintStream
.public static Log noopLog()
public abstract boolean isEnabled()
public abstract Log string(String value)
public abstract Log string(String str, int fill, int align)
public abstract Log string(char[] value)
public final Log string(byte[] value)
public abstract Log string(byte[] value, int offset, int length)
public abstract Log string(org.graalvm.nativeimage.c.type.CCharPointer value)
public abstract Log character(char value)
public abstract Log newline()
public abstract Log autoflush(boolean onOrOff)
onOrOff
- true if auto-flush must be turned on, false otherwise.public abstract Log number(long value, int radix, boolean signed)
value
- The value to print.radix
- The base of the value, between 2 and 36.signed
- true if the value should be treated as a signed value (and the digits are
preceded by '-' for negative values).public abstract Log signed(org.graalvm.word.WordBase value)
public abstract Log signed(int value)
public abstract Log signed(long value)
public abstract Log unsigned(org.graalvm.word.WordBase value)
public abstract Log unsigned(org.graalvm.word.WordBase value, int fill, int align)
public abstract Log unsigned(int value)
public abstract Log unsigned(long value)
public abstract Log unsigned(long value, int fill, int align)
public abstract Log rational(long numerator, long denominator, long decimals)
public abstract Log hex(org.graalvm.word.WordBase value)
public abstract Log hex(int value)
public abstract Log hex(long value)
public abstract Log zhex(long value)
public abstract Log zhex(int value)
public abstract Log zhex(short value)
public abstract Log zhex(byte value)
public abstract Log hexdump(org.graalvm.word.PointerBase from, int wordSize, int numWords)
from
- pointer to memory where dumping should start fromwordSize
- size in bytes that a single word should havenumWords
- number of words to dumppublic abstract Log redent(boolean addOrRemove)
public final Log indent(boolean addOrRemove)
public abstract Log bool(boolean value)
public abstract Log object(Object value)
public abstract Log spaces(int value)
public Log exception(Throwable t)
public abstract Log exception(Throwable t, int maxFrames)
public abstract Log flush()
public void close()
close
in interface AutoCloseable