< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotTTYStreamProvider.java
Print this page
rev 56282 : [mq]: graal
*** 51,61 ****
public static class Options {
// @formatter:off
@Option(help = "File to which logging is sent. A %p in the name will be replaced with a string identifying " +
! "the process, usually the process id and %t will be replaced by System.currentTimeMillis().", type = OptionType.Expert)
public static final LogStreamOptionKey LogFile = new LogStreamOptionKey();
// @formatter:on
}
@Override
--- 51,62 ----
public static class Options {
// @formatter:off
@Option(help = "File to which logging is sent. A %p in the name will be replaced with a string identifying " +
! "the process, usually the process id and %t will be replaced by System.currentTimeMillis(). " +
! "Using %o as filename sends logging to System.out whereas %e sends logging to System.err.", type = OptionType.Expert)
public static final LogStreamOptionKey LogFile = new LogStreamOptionKey();
// @formatter:on
}
@Override
*** 75,94 ****
}
/**
* @return {@code nameTemplate} with all instances of %p replaced by
* {@link GraalServices#getExecutionID()} and %t by
! * {@link System#currentTimeMillis()}
*/
private static String makeFilename(String nameTemplate) {
String name = nameTemplate;
if (name.contains("%p")) {
name = name.replaceAll("%p", GraalServices.getExecutionID());
}
if (name.contains("%t")) {
name = name.replaceAll("%t", String.valueOf(System.currentTimeMillis()));
}
return name;
}
/**
* An output stream that redirects to {@link HotSpotJVMCIRuntime#getLogStream()}. The
--- 76,103 ----
}
/**
* @return {@code nameTemplate} with all instances of %p replaced by
* {@link GraalServices#getExecutionID()} and %t by
! * {@link System#currentTimeMillis()}. Checks %o and %e are not combined with any
! * other characters.
*/
private static String makeFilename(String nameTemplate) {
String name = nameTemplate;
if (name.contains("%p")) {
name = name.replaceAll("%p", GraalServices.getExecutionID());
}
if (name.contains("%t")) {
name = name.replaceAll("%t", String.valueOf(System.currentTimeMillis()));
}
+
+ for (String subst : new String[]{"%o", "%e"}) {
+ if (name.contains(subst) && !name.equals(subst)) {
+ throw new IllegalArgumentException("LogFile substitution " + subst + " cannot be combined with any other characters");
+ }
+ }
+
return name;
}
/**
* An output stream that redirects to {@link HotSpotJVMCIRuntime#getLogStream()}. The
*** 104,127 ****
synchronized (this) {
if (lazy == null) {
String nameTemplate = LogStreamOptionKey.this.getValue(defaultOptions());
if (nameTemplate != null) {
String name = makeFilename(nameTemplate);
try {
final boolean enableAutoflush = true;
FileOutputStream result = new FileOutputStream(name);
if (!Services.IS_IN_NATIVE_IMAGE) {
printVMConfig(enableAutoflush, result);
} else {
! // There are no VM arguments for the libgraal library.
}
lazy = result;
- return lazy;
} catch (FileNotFoundException e) {
throw new RuntimeException("couldn't open file: " + name, e);
}
}
lazy = HotSpotJVMCIRuntime.runtime().getLogStream();
PrintStream ps = new PrintStream(lazy);
ps.printf("[Use -D%sLogFile=<path> to redirect Graal log output to a file.]%n", GRAAL_OPTION_PROPERTY_PREFIX);
ps.flush();
--- 113,146 ----
synchronized (this) {
if (lazy == null) {
String nameTemplate = LogStreamOptionKey.this.getValue(defaultOptions());
if (nameTemplate != null) {
String name = makeFilename(nameTemplate);
+ switch (name) {
+ case "%o":
+ lazy = System.out;
+ break;
+ case "%e":
+ lazy = System.err;
+ break;
+ default:
try {
final boolean enableAutoflush = true;
FileOutputStream result = new FileOutputStream(name);
if (!Services.IS_IN_NATIVE_IMAGE) {
printVMConfig(enableAutoflush, result);
} else {
! // There are no VM arguments for the libgraal
! // library.
}
lazy = result;
} catch (FileNotFoundException e) {
throw new RuntimeException("couldn't open file: " + name, e);
}
}
+ return lazy;
+ }
lazy = HotSpotJVMCIRuntime.runtime().getLogStream();
PrintStream ps = new PrintStream(lazy);
ps.printf("[Use -D%sLogFile=<path> to redirect Graal log output to a file.]%n", GRAAL_OPTION_PROPERTY_PREFIX);
ps.flush();
< prev index next >