001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package com.sun.midp.log;
028:
029: import com.sun.midp.configurator.Constants;
030:
031: /**
032: * The purpose of the logging service is to provide a standard means
033: * to report runtime information from within Java or native code.
034: * The porting process is eased by having to modify one logging
035: * service implementation in place of handling the ad hoc use of
036: * <code>println()</code>, <code>printf()</code>, <code>putc()</code>,
037: * and other functions currently used.
038: *
039: * An assert mechanism for Java code, implemented using the logging
040: * service is also provided here for convenience.
041: *
042: * This class consists of the Java interface to the functionality
043: * of the logging service.
044: */
045: public class Logging extends LoggingBase {
046:
047: /**
048: * Flag allowing client code with reporting levels less
049: * than this to be compiled out of the build. Callers
050: * should use this flag as a way to remove bytecodes
051: * related to unneeded levels of reporting from the
052: * resulting classfiles.
053: * For Example:
054: * <pre><code>
055: * if (Logging.REPORT_LEVEL <= severity) {
056: * Logging.report(Logging.<severity>,
057: * LogChannels.<channel>,
058: * "[meaningful message]");
059: * }
060: * </code></pre>
061: */
062: public static final int REPORT_LEVEL = Constants.REPORT_LEVEL;
063:
064: /**
065: * Flag allowing client code with assert statements
066: * to be compiled out of a production build. Clients of
067: * the assertion service should wrap calls to the
068: * <code>assert()</code> method to enable them to be
069: * removed from builds when desired
070: * <pre><code>
071: * if (Logging.ASSERT_ENABLED) {
072: * Logging.assertTrue([eval to boolean], "message");
073: * }
074: * </code></pre>
075: */
076: public static final boolean ASSERT_ENABLED = true;
077:
078: /**
079: * Flag to indicate whether tracing is enabled in the
080: * Logging service. If the flag is <code>false</code>,
081: * calls to the <code>trace()</code> method will have
082: * no effect. Callers should use this flag as a type of
083: * compile option to remove unnecessary bytecodes from
084: * resulting classfiles.
085: *
086: * For example:
087: * <code><pre>
088: * } catch (Throwable t) {
089: * if (Logging.TRACE_ENABLED) {
090: * Logging.trace(t, "[meaningful message]");
091: * }
092: * }
093: * </pre></code>
094: */
095: public static final boolean TRACE_ENABLED = false;
096:
097: /**
098: * Loads the logging settings for the specified suite.
099: *
100: * @param suiteId ID of the suite for which the settings must be loaded
101: */
102: public static void initLogSettings(int suiteId) {
103: }
104:
105: /**
106: * Sets a new report level.
107: *
108: * @param newReportLevel new report level
109: */
110: public static void setReportLevel(int newReportLevel) {
111: }
112:
113: /**
114: * Enables or disables tracing.
115: *
116: * @param enabled > 0 - enable tracing, == 0 - disable it,
117: * < 0 - don't change the current setting
118: */
119: public static void enableTrace(int enabled) {
120: }
121:
122: /**
123: * Enables or disables assertions.
124: *
125: * @param enabled > 0 - enable assertions, == 0 - disable it,
126: * < 0 - don't change the current setting
127: */
128: public static void enableAssert(int enabled) {
129: }
130: }
|