< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotTTYStreamProvider.java

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 package org.graalvm.compiler.hotspot;
  26 
  27 import static org.graalvm.compiler.hotspot.HotSpotGraalOptionValues.GRAAL_OPTION_PROPERTY_PREFIX;
  28 import static org.graalvm.compiler.hotspot.HotSpotGraalOptionValues.HOTSPOT_OPTIONS;
  29 
  30 import java.io.FileNotFoundException;
  31 import java.io.FileOutputStream;
  32 import java.io.IOException;
  33 import java.io.OutputStream;
  34 import java.io.PrintStream;
  35 import java.util.List;
  36 
  37 import org.graalvm.compiler.core.common.SuppressFBWarnings;
  38 import org.graalvm.compiler.debug.TTYStreamProvider;
  39 import org.graalvm.compiler.options.Option;
  40 import org.graalvm.compiler.options.OptionKey;
  41 import org.graalvm.compiler.options.OptionType;
  42 import org.graalvm.compiler.options.OptionValues;
  43 import org.graalvm.compiler.serviceprovider.GraalServices;
  44 import org.graalvm.compiler.serviceprovider.ServiceProvider;
  45 
  46 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
  47 
  48 @ServiceProvider(TTYStreamProvider.class)
  49 public class HotSpotTTYStreamProvider implements TTYStreamProvider {
  50 
  51     public static class Options {
  52 
  53         // @formatter:off
  54         @Option(help = "File to which logging is sent.  A %p in the name will be replaced with a string identifying " +
  55                        "the process, usually the process id and %t will be replaced by System.currentTimeMillis().", type = OptionType.Expert)
  56         public static final LogStreamOptionKey LogFile = new LogStreamOptionKey();
  57         // @formatter:on
  58     }
  59 
  60     @Override
  61     public PrintStream getStream() {
  62         return Options.LogFile.getStream(HOTSPOT_OPTIONS);
  63     }
  64 
  65     /**
  66      * An option for a configurable file name that can also open a {@link PrintStream} on the file.
  67      * If no value is given for the option, the stream will output to HotSpot's
  68      * {@link HotSpotJVMCIRuntime#getLogStream() log} stream
  69      */
  70     private static class LogStreamOptionKey extends OptionKey<String> {
  71 
  72         LogStreamOptionKey() {
  73             super(null);
  74         }
  75 
  76         /**
  77          * @return {@code nameTemplate} with all instances of %p replaced by
  78          *         {@link GraalServices#getExecutionID()} and %t by
  79          *         {@link System#currentTimeMillis()}
  80          */
  81         private static String makeFilename(String nameTemplate) {
  82             String name = nameTemplate;




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 package org.graalvm.compiler.hotspot;
  26 
  27 import static org.graalvm.compiler.hotspot.HotSpotGraalOptionValues.GRAAL_OPTION_PROPERTY_PREFIX;
  28 import static org.graalvm.compiler.hotspot.HotSpotGraalOptionValues.defaultOptions;
  29 
  30 import java.io.FileNotFoundException;
  31 import java.io.FileOutputStream;
  32 import java.io.IOException;
  33 import java.io.OutputStream;
  34 import java.io.PrintStream;
  35 import java.util.List;
  36 
  37 import org.graalvm.compiler.core.common.SuppressFBWarnings;
  38 import org.graalvm.compiler.debug.TTYStreamProvider;
  39 import org.graalvm.compiler.options.Option;
  40 import org.graalvm.compiler.options.OptionKey;
  41 import org.graalvm.compiler.options.OptionType;
  42 import org.graalvm.compiler.options.OptionValues;
  43 import org.graalvm.compiler.serviceprovider.GraalServices;
  44 import org.graalvm.compiler.serviceprovider.ServiceProvider;
  45 
  46 import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
  47 
  48 @ServiceProvider(TTYStreamProvider.class)
  49 public class HotSpotTTYStreamProvider implements TTYStreamProvider {
  50 
  51     public static class Options {
  52 
  53         // @formatter:off
  54         @Option(help = "File to which logging is sent.  A %p in the name will be replaced with a string identifying " +
  55                        "the process, usually the process id and %t will be replaced by System.currentTimeMillis().", type = OptionType.Expert)
  56         public static final LogStreamOptionKey LogFile = new LogStreamOptionKey();
  57         // @formatter:on
  58     }
  59 
  60     @Override
  61     public PrintStream getStream() {
  62         return Options.LogFile.getStream(defaultOptions());
  63     }
  64 
  65     /**
  66      * An option for a configurable file name that can also open a {@link PrintStream} on the file.
  67      * If no value is given for the option, the stream will output to HotSpot's
  68      * {@link HotSpotJVMCIRuntime#getLogStream() log} stream
  69      */
  70     private static class LogStreamOptionKey extends OptionKey<String> {
  71 
  72         LogStreamOptionKey() {
  73             super(null);
  74         }
  75 
  76         /**
  77          * @return {@code nameTemplate} with all instances of %p replaced by
  78          *         {@link GraalServices#getExecutionID()} and %t by
  79          *         {@link System#currentTimeMillis()}
  80          */
  81         private static String makeFilename(String nameTemplate) {
  82             String name = nameTemplate;


< prev index next >