xref: /illumos-gate/usr/src/lib/libslp/javalib/com/sun/slp/StderrLog.java (revision d8d810637042c2a73a269f125dee75e8ed1421d1)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * ident	"%Z%%M%	%I%	%E% SMI"
24  *
25  * Copyright (c) 1999 by Sun Microsystems, Inc.
26  * All rights reserved.
27  *
28  */
29 
30 package com.sun.slp;
31 
32 import java.io.*;
33 
34 /**
35  * A logging class which writes to stderr. This class can be dynamically
36  * loaded by SLPConfig and used as the log object by the writeLog and
37  * writeLogLine methods.
38  *
39  * This class does not actually write anything until the flush() method
40  * in invoked; this will write the concatenation of all messages
41  * passed to the write() method since the last invokation of flush().
42  *
43  * The actual logging class used can be controlled via the
44  * sun.net.slp.loggerClass property.
45  *
46  * See also the SLPLog (in slpd.java) and Syslog classes.
47  */
48 
49 class StderrLog extends Writer {
50 
51     private StringBuffer buf;
52 
53     public StderrLog() {
54 	buf = new StringBuffer();
55     }
56 
57     public void write(char[] cbuf, int off, int len) throws IOException {
58 	buf.append(cbuf, off, len);
59     }
60 
61     public void flush() {
62 	String date = SLPConfig.getDateString();
63 
64 	System.err.println("********" +
65 			   date + "\n" +
66 			   buf + "\n" +
67 			   "********\n");
68 	buf = new StringBuffer();
69     }
70 
71     public void close() {
72     }
73 }
74