Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/com/sun/tools/sjavac/Log.java
38899 views
/*1* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.tools.sjavac;2627import java.io.PrintStream;2829/**30* Utility class only for sjavac logging.31* The log level can be set using for example --log=DEBUG on the sjavac command line.32*33* <p><b>This is NOT part of any supported API.34* If you write code that depends on this, you do so at your own35* risk. This code and its internal interfaces are subject to change36* or deletion without notice.</b></p>37*/38public class Log {39private static PrintStream out, err;4041public final static int WARN = 1;42public final static int INFO = 2;43public final static int DEBUG = 3;44public final static int TRACE = 4;45private static int level = WARN;4647static public void trace(String msg) {48if (level >= TRACE) {49out.println(msg);50}51}5253static public void debug(String msg) {54if (level >= DEBUG) {55out.println(msg);56}57}5859static public void info(String msg) {60if (level >= INFO) {61out.println(msg);62}63}6465static public void warn(String msg) {66err.println(msg);67}6869static public void error(String msg) {70err.println(msg);71}7273static public void setLogLevel(String l, PrintStream o, PrintStream e)74throws ProblemException {75out = o;76err = e;77if (l.equals("warn")) level = WARN;78else if (l.equals("info")) level = INFO;79else if (l.equals("debug")) level = DEBUG;80else if (l.equals("trace")) level = TRACE;81else throw new ProblemException("No such log level \""+l+"\"");82}8384static public boolean isTracing() {85return level >= TRACE;86}8788static public boolean isDebugging() {89return level >= DEBUG;90}91}929394