src/java.rmi/share/classes/java/rmi/server/LogStream.java
author rriggs
Wed, 02 Oct 2019 13:57:03 -0400
changeset 58446 5c83830390ba
parent 47216 71c04702a3d5
permissions -rw-r--r--
8231663: Incorrect GPL header in some RMI/SQL package-info.java files Reviewed-by: bpb, iris, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
16874
acf47f31a0da 8001329: Augment RMI logging
dmocek
parents: 14342
diff changeset
     2
 * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package java.rmi.server;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * <code>LogStream</code> provides a mechanism for logging errors that are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * of possible interest to those monitoring a system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * @author  Ann Wollrath (lots of code stolen from Ken Arnold)
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 16874
diff changeset
    35
 * @since   1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * @deprecated no replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
@Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
public class LogStream extends PrintStream {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    /** table mapping known log names to log stream objects */
11117
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 5506
diff changeset
    42
    private static Map<String,LogStream> known = new HashMap<>(5);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    /** default output stream for new logs */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    private static PrintStream  defaultStream = System.err;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    /** log name for this log */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    /** stream where output of this log is sent to */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private OutputStream logOut;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /** string writer for writing message prefixes to log stream */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private OutputStreamWriter logWriter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    /** string buffer used for constructing log message prefixes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private StringBuffer buffer = new StringBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /** stream used for buffering lines */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private ByteArrayOutputStream bufOut;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Create a new LogStream object.  Since this only constructor is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * private, users must have a LogStream created through the "log"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * @param name string identifying messages from this log
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * @out output stream that log messages will be sent to
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 16874
diff changeset
    67
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @deprecated no replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private LogStream(String name, OutputStream out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        super(new ByteArrayOutputStream());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        bufOut = (ByteArrayOutputStream) super.out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        setOutputStream(out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * Return the LogStream identified by the given name.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * a log corresponding to "name" does not exist, a log using
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * the default stream is created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @param name name identifying the desired LogStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @return log associated with given name
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 16874
diff changeset
    86
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @deprecated no replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public static LogStream log(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        LogStream stream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        synchronized (known) {
11117
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 5506
diff changeset
    93
            stream = known.get(name);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            if (stream == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                stream = new LogStream(name, defaultStream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            known.put(name, stream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        return stream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * Return the current default stream for new logs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * @return default log stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * @see #setDefaultStream
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 16874
diff changeset
   106
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @deprecated no replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public static synchronized PrintStream getDefaultStream() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        return defaultStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * Set the default stream for new logs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @param newDefault new default log stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @see #getDefaultStream
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 16874
diff changeset
   118
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @deprecated no replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    public static synchronized void setDefaultStream(PrintStream newDefault) {
16874
acf47f31a0da 8001329: Augment RMI logging
dmocek
parents: 14342
diff changeset
   123
        SecurityManager sm = System.getSecurityManager();
acf47f31a0da 8001329: Augment RMI logging
dmocek
parents: 14342
diff changeset
   124
acf47f31a0da 8001329: Augment RMI logging
dmocek
parents: 14342
diff changeset
   125
        if (sm != null) {
acf47f31a0da 8001329: Augment RMI logging
dmocek
parents: 14342
diff changeset
   126
            sm.checkPermission(
acf47f31a0da 8001329: Augment RMI logging
dmocek
parents: 14342
diff changeset
   127
                new java.util.logging.LoggingPermission("control", null));
acf47f31a0da 8001329: Augment RMI logging
dmocek
parents: 14342
diff changeset
   128
        }
acf47f31a0da 8001329: Augment RMI logging
dmocek
parents: 14342
diff changeset
   129
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        defaultStream = newDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * Return the current stream to which output from this log is sent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @return output stream for this log
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @see #setOutputStream
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 16874
diff changeset
   137
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @deprecated no replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    public synchronized OutputStream getOutputStream()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        return logOut;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * Set the stream to which output from this log is sent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @param out new output stream for this log
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @see #getOutputStream
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 16874
diff changeset
   150
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @deprecated no replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    public synchronized void setOutputStream(OutputStream out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        logOut = out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        // Maintain an OutputStreamWriter with default CharToByteConvertor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        // (just like new PrintStream) for writing log message prefixes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        logWriter = new OutputStreamWriter(logOut);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * Write a byte of data to the stream.  If it is not a newline, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * the byte is appended to the internal buffer.  If it is a newline,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * then the currently buffered line is sent to the log's output
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * stream, prefixed with the appropriate logging information.
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 16874
diff changeset
   167
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @deprecated no replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    public void write(int b)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        if (b == '\n') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            // synchronize on "this" first to avoid potential deadlock
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                synchronized (logOut) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                    // construct prefix for log messages:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                    buffer.setLength(0);;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                    buffer.append(              // date/time stamp...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                        (new Date()).toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                    buffer.append(':');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                    buffer.append(name);        // ...log name...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                    buffer.append(':');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                    buffer.append(Thread.currentThread().getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                    buffer.append(':'); // ...and thread name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                        // write prefix through to underlying byte stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                        logWriter.write(buffer.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                        logWriter.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                        // finally, write the already converted bytes of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                        // the log message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                        bufOut.writeTo(logOut);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                        logOut.write(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                        logOut.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                    } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                        setError();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                    } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                        bufOut.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            super.write(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * Write a subarray of bytes.  Pass each through write byte method.
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 16874
diff changeset
   211
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @deprecated no replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    public void write(byte b[], int off, int len)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        if (len < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            throw new ArrayIndexOutOfBoundsException(len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        for (int i = 0; i < len; ++ i)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            write(b[off + i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * Return log name as string representation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * @return log name
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 16874
diff changeset
   226
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @deprecated no replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public String toString()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    /** log level constant (no logging). */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    public static final int SILENT  = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    /** log level constant (brief logging). */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    public static final int BRIEF   = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    /** log level constant (verbose logging). */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public static final int VERBOSE = 20;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * Convert a string name of a logging level to its internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * integer representation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * @param s name of logging level (e.g., 'SILENT', 'BRIEF', 'VERBOSE')
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * @return corresponding integer log level
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 16874
diff changeset
   247
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @deprecated no replacement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    public static int parseLevel(String s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        if ((s == null) || (s.length() < 1))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            return Integer.parseInt(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        } catch (NumberFormatException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        if (s.length() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        if ("SILENT".startsWith(s.toUpperCase()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            return SILENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        else if ("BRIEF".startsWith(s.toUpperCase()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            return BRIEF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        else if ("VERBOSE".startsWith(s.toUpperCase()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            return VERBOSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
}